Class AjaxRequestHandler

  • All Implemented Interfaces:
    AjaxRequestTarget, IPageClassRequestHandler, IPageRequestHandler, IPartialPageRequestHandler, ILoggableRequestHandler, IRequestHandler

    public class AjaxRequestHandler
    extends AbstractPartialPageRequestHandler
    implements AjaxRequestTarget
    A request target that produces ajax response envelopes used on the client side to update component markup as well as evaluate arbitrary javascript.

    A component whose markup needs to be updated should be added to this target via AjaxRequestTarget#add(Component) method. Its body will be rendered and added to the envelope when the target is processed, and refreshed on the client side when the ajax response is received.

    It is important that the component whose markup needs to be updated contains an id attribute in the generated markup that is equal to the value retrieved from Component#getMarkupId(). This can be accomplished by either setting the id attribute in the html template, or using an attribute modifier that will add the attribute with value Component#getMarkupId() to the tag ( such as MarkupIdSetter )

    Any javascript that needs to be evaluated on the client side can be added using AjaxRequestTarget#append/prependJavaScript(String). For example, this feature can be useful when it is desirable to link component update with some javascript effects.

    The target provides a listener interface AjaxRequestTarget.IListener that can be used to add code that responds to various target events by adding listeners via addListener(AjaxRequestTarget.IListener)

    Since:
    1.2
    Author:
    Igor Vaynberg (ivaynberg), Eelco Hillenius