Class JsStatement
- All Implemented Interfaces:
Serializable
A JsStatement defines a whole executable JavaScript statement. The generator eases
"jQuery oriented" code, but you can still use another JavaScript coding style with the
append(CharSequence) method.
To get a valid instance and to ease JavaScript and Wicket integration, you should use the
JsQuery class (example below). This class will initialize a JsStatement and
contribute to a WebPage.
The JavaScript generating by a JsStatement is jQuery oriented. Example of generated string:
$(".aClassName").each(function() {alert('foo');});
To generate the script above, you can write this:
new JsQuery().$().each(JsScope.quickScope("alert('foo')"));
Any JsStatement should be returned by a JsQuery within the $
methods.
- Since:
- 0.7
- Author:
- Lionel Armanet
- See Also:
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription$()Appends the jQuery's$function to the currentJsStatement.$(org.apache.wicket.Component context) Same method as$(Component, String)with an empty selector.Appends the jQuery's$function to the currentJsStatement.Binds theaddClassstatement.after(CharSequence html) Binds theafterstatement.append(CharSequence charSequence) Appends the givenCharSequenceto this statement.Binds theattrstatement.Binds theattrstatement.before(CharSequence html) Binds thebeforestatement.chain(CharSequence statementLabel, CharSequence... statementArgs) Chains a function call to thisJsStatement.chain(ChainableStatement chainableStatement) Chains a function call to thisJsStatement.Binds thecssstatement.Binds thecssstatement.document()Appends $(document) to the statement.Appends the each jQuery statement.html(CharSequence htmlContents) Binds thehtmlstatement.insertAfter(String expression) Binds theinsertAfterstatement.insertBefore(String expression) Binds theinsertBeforestatement.Appends the ready jQuery statement.removeAttr(String key) Binds theremoveAttrstatement.removeClass(String className) Binds theremoveClassstatement.render()Renders this statement.render(boolean semicolon) Renders this statement.self()Appends thethiskeyword to this statement.toggleClass(String className) Binds thetoggleClassstatement.
-
Constructor Details
-
JsStatement
public JsStatement()Creates a newJsStatement.
-
-
Method Details
-
$
Appends the jQuery's$function to the currentJsStatement. So, we can call some special jquery fonction, like$.browser...- Returns:
JsStatementthis instance.
-
$
Same method as$(Component, String)with an empty selector.- Returns:
JsStatementthis instance.
-
$
Appends the jQuery's$function to the currentJsStatement. If context is not null, the generated JavaScript code will be:
If context is null, the generated JavaScript code will be:$("#component.getMarkupId selector")$("selector")- Returns:
JsStatementthis instance.
-
addClass
Binds theaddClassstatement. -
after
Binds theafterstatement. -
append
Appends the givenCharSequenceto this statement.- Returns:
JsStatementthis instance.
-
attr
Binds theattrstatement. -
attr
Binds theattrstatement. -
before
Binds thebeforestatement. -
chain
Chains a function call to thisJsStatement. The function call is wrapped in a ChainableStatement. (eases JavaScript integration).- Returns:
JsStatementthis instance.- See Also:
-
chain
Chains a function call to thisJsStatement. This will append statementLabel(statementArgs) to thisJsStatement.- Parameters:
statementLabel- the statement label to append.statementArgs- the statement args.- Returns:
JsStatementthis instance.
-
css
Binds thecssstatement. -
css
Binds thecssstatement. -
document
Appends $(document) to the statement.- Returns:
JsStatementthis instance.
-
each
Appends the each jQuery statement.- Parameters:
scope- theJsScopeto execute within every matched element.
-
getStatement
- Returns:
- the statement of the JsStatement
-
html
Binds thehtmlstatement. -
insertAfter
Binds theinsertAfterstatement. -
insertBefore
Binds theinsertBeforestatement. -
ready
Appends the ready jQuery statement.- Parameters:
scope- theJsScopeto execute when jQuery is ready.
-
removeAttr
Binds theremoveAttrstatement. -
removeClass
Binds theremoveClassstatement. -
render
Renders this statement.- Returns:
- the renderable JavaScript statement as a
CharSequence.
-
render
Renders this statement.- Parameters:
semicolon- If true, a semicolon is automatically added- Returns:
- the renderable JavaScript statement as a
CharSequence.
-
self
Appends thethiskeyword to this statement.- Returns:
JsStatementthis instance.
-
toggleClass
Binds thetoggleClassstatement.
-