org.odlabs.wiquery.core.javascript
Class JsQuery

java.lang.Object
  extended by org.apache.wicket.behavior.Behavior
      extended by org.odlabs.wiquery.core.javascript.JsQuery
All Implemented Interfaces:
Serializable, org.apache.wicket.IClusterable, org.apache.wicket.IComponentAwareEventSink, org.apache.wicket.markup.html.IComponentAwareHeaderContributor

public class JsQuery
extends org.apache.wicket.behavior.Behavior
implements Serializable

$Id$

JsQuery is the main entry point of WickeXt's JavaScript integration. This class is used to link JavaScript to a component and to render it.

This class implements the IHeaderContributor interface, so if you want to append the generated JavaScript, just do this:

        
 JsQuery jsq = new JsQuery(myComponent);
 jsq.$().chain("css", "border", "1px solid red");
 myComponent.add(new HeaderContributor(jsq));
 
 

If you want to generate a statement concerning a component, do it as below:

new JsQuery(yourComponent).$().chain("css", "border", "1px solid red"));

Since:
0.7
Author:
Lionel Armanet
See Also:
Serialized Form

Constructor Summary
JsQuery()
          Creates a new JsQuery.
JsQuery(org.apache.wicket.Component component)
          Creates a new JsQuery linked to a Component.
 
Method Summary
 JsStatement $()
           
 JsStatement $(String selector)
          Same as $() but with a specified CSS selector.
 void bind(org.apache.wicket.Component hostComponent)
           
 void contribute(org.apache.wicket.Component component)
          Deprecated. use Component.add(Behavior...).
 JsStatement document()
           
 JsStatement getStatement()
           
protected  void onBind()
          Called when the component was bound to it's host component.
 void renderHead(org.apache.wicket.Component component, org.apache.wicket.markup.html.IHeaderResponse response)
           
 void renderHead(org.apache.wicket.markup.html.IHeaderResponse response, org.apache.wicket.request.IRequestHandler requestHandler)
          FOR FRAMEWORK'S INTERNAL USE ONLY
 void setStatement(JsStatement jsStatement)
          FOR FRAMEWORK'S INTERNAL USE ONLY
 
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, canCallListenerInterface, canCallListenerInterface, detach, getStatelessHint, isEnabled, isTemporary, onComponentTag, onConfigure, onEvent, onException, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JsQuery

public JsQuery(org.apache.wicket.Component component)
Creates a new JsQuery linked to a Component.


JsQuery

public JsQuery()
Creates a new JsQuery.

Method Detail

$

public JsStatement $()
Returns:
a new JsStatement initialized with the $ statement.

$

public JsStatement $(String selector)
Same as $() but with a specified CSS selector. If this JsQuery is linked to a component, the resulting JavaScript code will be

$("#yourComponentId cssSelector")

Parameters:
selector -
Returns:

document

public JsStatement document()
Returns:
a new JsStatement initialized with the document statement.

renderHead

public void renderHead(org.apache.wicket.Component component,
                       org.apache.wicket.markup.html.IHeaderResponse response)
Specified by:
renderHead in interface org.apache.wicket.markup.html.IComponentAwareHeaderContributor
Overrides:
renderHead in class org.apache.wicket.behavior.Behavior

bind

public final void bind(org.apache.wicket.Component hostComponent)
Overrides:
bind in class org.apache.wicket.behavior.Behavior

onBind

protected void onBind()
Called when the component was bound to it's host component. You can get the bound host component by calling getComponent.


getStatement

public JsStatement getStatement()
Returns:
the statement

setStatement

public void setStatement(JsStatement jsStatement)
FOR FRAMEWORK'S INTERNAL USE ONLY


contribute

@Deprecated
public void contribute(org.apache.wicket.Component component)
Deprecated. use Component.add(Behavior...).

Adds this statement as Behavior to the component. When the page or ajax request is rendered this statement will be added.


renderHead

public void renderHead(org.apache.wicket.markup.html.IHeaderResponse response,
                       org.apache.wicket.request.IRequestHandler requestHandler)
FOR FRAMEWORK'S INTERNAL USE ONLY



Copyright © 2012. All Rights Reserved.