|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.apache.click.ajax.DefaultAjaxBehavior
public class DefaultAjaxBehavior
Provides a default implementation of the AjaxBehavior interface.
This class also provides the method,addHeadElementsOnce,
that subclasses can implement if they need to add HTML HEAD elements only to
the first Control that this Behavior is registered with.
If this Behavior should add HTML HEAD elements to all the Controls it is
registered with, rather implement
preRenderHeadElements.
| Field Summary | |
|---|---|
protected boolean |
headElementsProcessed
Indicates whether the Behavior HEAD elements have been processed or not. |
| Constructor Summary | |
|---|---|
DefaultAjaxBehavior()
|
|
| Method Summary | |
|---|---|
protected void |
addHeadElementsOnce(Control source)
Provides a method for adding HTML HEAD elements to the first Control this Behavior was registered with. |
boolean |
isAjaxTarget(Context context)
Return true if the behavior is the request target, false otherwise. |
ActionResult |
onAction(Control source)
This method can be implemented to handle and respond to an Ajax request. |
void |
preDestroy(Control source)
This event occurs before the Control onDestroy
event handler. |
void |
preRenderHeadElements(Control source)
This event occurs after Behavior.preResponse(org.apache.click.Control),
but before the Control's Control.getHeadElements() is called. |
void |
preResponse(Control source)
This event occurs before the markup is written to the HttpServletResponse. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
protected boolean headElementsProcessed
| Constructor Detail |
|---|
public DefaultAjaxBehavior()
| Method Detail |
|---|
public ActionResult onAction(Control source)
AjaxBehavior
public void onInit() {
ActionLink link = new ActionLink("link");
link.addBehaior(new DefaultAjaxBehavior() {
public ActionResult onAction(Control source) {
ActionResult result = new ActionResult("<h1>Hello world</h1>", ActionResult.HTML);
return result;
}
});
}
onAction in interface AjaxBehaviorsource - the control the behavior is registered with
AjaxBehavior.onAction(org.apache.click.Control)public boolean isAjaxTarget(Context context)
AjaxBehaviorAjaxBehavior.onAction(org.apache.click.Control) method should be called in
response to a request.
By exposing this method through the Behavior interface it provides
implementers with fine grained control over whether the Behavior's
AjaxBehavior.onAction(org.apache.click.Control) method should be invoked or not.
Below is an example implementation:
public CustomBehavior implements Behavior {
private String eventType;
public CustomBehavior(String eventType) {
// The event type of the behavior
super(eventType);
}
public boolean isAjaxTarget(Context context) {
// Retrieve the eventType parameter from the incoming request
String eventType = context.getRequestParameter("type");
// Check if this Behavior's eventType matches the request
// "type" parameter
return StringUtils.equalsIgnoreCase(this.eventType, eventType);
}
public ActionResult onAction(Control source) {
// If isAjaxTarget returned true, the onAction method will be
// invoked
...
}
}
isAjaxTarget in interface AjaxBehaviorcontext - the request context
AjaxBehavior.isAjaxTarget(org.apache.click.Context)public void preResponse(Control source)
Behavior
preResponse in interface Behaviorsource - the control the behavior is registered withBehavior.preResponse(org.apache.click.Control)public void preRenderHeadElements(Control source)
BehaviorBehavior.preResponse(org.apache.click.Control),
but before the Control's Control.getHeadElements() is called.
preRenderHeadElements in interface Behaviorsource - the control the behavior is registered withBehavior.preRenderHeadElements(org.apache.click.Control)public void preDestroy(Control source)
BehavioronDestroy
event handler. This event allows the behavior to cleanup or store Control
state in the Session.
preDestroy in interface Behaviorsource - the control the behavior is registered withBehavior.preDestroy(org.apache.click.Control)protected void addHeadElementsOnce(Control source)
preRenderHeadElements(org.apache.click.Control) if HTML HEAD
elements should only be added to one Control, even if the Behavior is
added to multiple Controls.
source - the control the behavior is registered with
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||