Class JsStatement
- java.lang.Object
-
- org.wicketstuff.wiquery.core.javascript.JsStatement
-
- All Implemented Interfaces:
java.io.Serializable
public class JsStatement extends java.lang.Object implements java.io.Serializable$Id: JsStatement.java 1714M 2012-01-17 08:35:15Z (local) $A
JsStatementdefines a whole executable JavaScript statement. The generator eases "jQuery oriented" code, but you can still use another JavaScript coding style with theappend(CharSequence)method.To get a valid instance and to ease JavaScript and Wicket integration, you should use the
JsQueryclass (example below). This class will initialize aJsStatementand contribute to aWebPage.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
JsStatementshould be returned by aJsQuerywithin the$methods.- Since:
- 0.7
- Author:
- Lionel Armanet
- See Also:
JsQuery,JsScope, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description JsStatement()Creates a newJsStatement.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description JsStatement$()Appends the jQuery's$function to the currentJsStatement.JsStatement$(org.apache.wicket.Component context)Same method as$(Component, String)with an empty selector.JsStatement$(org.apache.wicket.Component context, java.lang.String selector)Appends the jQuery's$function to the currentJsStatement.JsStatementaddClass(java.lang.String className)Binds theaddClassstatement.JsStatementafter(java.lang.CharSequence html)Binds theafterstatement.JsStatementappend(java.lang.CharSequence charSequence)Appends the givenCharSequenceto this statement.JsStatementattr(java.lang.String key, java.lang.String value)Binds theattrstatement.JsStatementattr(java.lang.String key, JsScope computedValue)Binds theattrstatement.JsStatementbefore(java.lang.CharSequence html)Binds thebeforestatement.JsStatementchain(java.lang.CharSequence statementLabel, java.lang.CharSequence... statementArgs)Chains a function call to thisJsStatement.JsStatementchain(ChainableStatement chainableStatement)Chains a function call to thisJsStatement.JsStatementcss(java.lang.String name, java.lang.String value)Binds thecssstatement.JsStatementcss(Options options)Binds thecssstatement.JsStatementdocument()Appends $(document) to the statement.JsStatementeach(JsScope scope)Appends the each jQuery statement.java.lang.StringBuildergetStatement()JsStatementhtml(java.lang.CharSequence htmlContents)Binds thehtmlstatement.JsStatementinsertAfter(java.lang.String expression)Binds theinsertAfterstatement.JsStatementinsertBefore(java.lang.String expression)Binds theinsertBeforestatement.JsStatementready(JsScope scope)Appends the ready jQuery statement.JsStatementremoveAttr(java.lang.String key)Binds theremoveAttrstatement.JsStatementremoveClass(java.lang.String className)Binds theremoveClassstatement.java.lang.CharSequencerender()Renders this statement.java.lang.CharSequencerender(boolean semicolon)Renders this statement.JsStatementself()Appends thethiskeyword to this statement.JsStatementtoggleClass(java.lang.String className)Binds thetoggleClassstatement.
-
-
-
Constructor Detail
-
JsStatement
public JsStatement()
Creates a newJsStatement.
-
-
Method Detail
-
$
public JsStatement $()
Appends the jQuery's$function to the currentJsStatement. So, we can call some special jquery fonction, like$.browser...- Returns:
JsStatementthis instance.
-
$
public JsStatement $(org.apache.wicket.Component context)
Same method as$(Component, String)with an empty selector.- Returns:
JsStatementthis instance.
-
$
public JsStatement $(org.apache.wicket.Component context, java.lang.String selector)
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
public JsStatement addClass(java.lang.String className)
Binds theaddClassstatement.
-
after
public JsStatement after(java.lang.CharSequence html)
Binds theafterstatement.
-
append
public JsStatement append(java.lang.CharSequence charSequence)
Appends the givenCharSequenceto this statement.- Returns:
JsStatementthis instance.
-
attr
public JsStatement attr(java.lang.String key, JsScope computedValue)
Binds theattrstatement.
-
attr
public JsStatement attr(java.lang.String key, java.lang.String value)
Binds theattrstatement.
-
before
public JsStatement before(java.lang.CharSequence html)
Binds thebeforestatement.
-
chain
public JsStatement chain(ChainableStatement chainableStatement)
Chains a function call to thisJsStatement. The function call is wrapped in a ChainableStatement. (eases JavaScript integration).- Returns:
JsStatementthis instance.- See Also:
chain(CharSequence, CharSequence...)
-
chain
public JsStatement chain(java.lang.CharSequence statementLabel, java.lang.CharSequence... statementArgs)
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
public JsStatement css(Options options)
Binds thecssstatement.
-
css
public JsStatement css(java.lang.String name, java.lang.String value)
Binds thecssstatement.
-
document
public JsStatement document()
Appends $(document) to the statement.- Returns:
JsStatementthis instance.
-
each
public JsStatement each(JsScope scope)
Appends the each jQuery statement.- Parameters:
scope- theJsScopeto execute within every matched element.
-
getStatement
public java.lang.StringBuilder getStatement()
- Returns:
- the statement of the JsStatement
-
html
public JsStatement html(java.lang.CharSequence htmlContents)
Binds thehtmlstatement.
-
insertAfter
public JsStatement insertAfter(java.lang.String expression)
Binds theinsertAfterstatement.
-
insertBefore
public JsStatement insertBefore(java.lang.String expression)
Binds theinsertBeforestatement.
-
ready
public JsStatement ready(JsScope scope)
Appends the ready jQuery statement.- Parameters:
scope- theJsScopeto execute when jQuery is ready.
-
removeAttr
public JsStatement removeAttr(java.lang.String key)
Binds theremoveAttrstatement.
-
removeClass
public JsStatement removeClass(java.lang.String className)
Binds theremoveClassstatement.
-
render
public java.lang.CharSequence render()
Renders this statement.- Returns:
- the renderable JavaScript statement as a
CharSequence.
-
render
public java.lang.CharSequence render(boolean semicolon)
Renders this statement.- Parameters:
semicolon- If true, a semicolon is automatically added- Returns:
- the renderable JavaScript statement as a
CharSequence.
-
self
public JsStatement self()
Appends thethiskeyword to this statement.- Returns:
JsStatementthis instance.
-
toggleClass
public JsStatement toggleClass(java.lang.String className)
Binds thetoggleClassstatement.
-
-