Class AbstractPartialPageRequestHandler
- java.lang.Object
-
- org.apache.wicket.core.request.handler.AbstractPartialPageRequestHandler
-
- All Implemented Interfaces:
IPageClassRequestHandler
,IPageRequestHandler
,IPartialPageRequestHandler
,IRequestHandler
- Direct Known Subclasses:
AjaxRequestHandler
,WebSocketRequestHandler
public abstract class AbstractPartialPageRequestHandler extends Object implements IPartialPageRequestHandler
AbstractIPartialPageRequestHandler
that implements common methods for Ajax and Web-sockets specializations ofIPartialPageRequestHandler
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractPartialPageRequestHandler(Page page)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
add(Component... components)
Adds components to the list of components to be rendered.void
add(Component component, String markupId)
Adds a component to the list of components to be renderedvoid
addChildren(MarkupContainer parent, Class<?> childCriteria)
Visits all children of the specified parent container and adds them to the target if they are of same type aschildCriteria
void
appendJavaScript(CharSequence javascript)
Add JavasSript that will be evaluated on the client side after components are replacedvoid
focusComponent(Component component)
Sets the focus in the browser to the given component.IHeaderResponse
getHeaderResponse()
Returns the header response associated with current handler.Page
getPage()
Returns the page.Class<? extends IRequestablePage>
getPageClass()
Returns the page classInteger
getPageId()
Returns the page id.PageParameters
getPageParameters()
Integer
getRenderCount()
Returns the number of times this page has been rendered.protected abstract PartialPageUpdate
getUpdate()
boolean
isPageInstanceCreated()
Checks if the page instance is already created or if it will be created whenIPageRequestHandler.getPage()
is calledvoid
prependJavaScript(CharSequence javascript)
Add JavaScript that will be evaluated on the client side before components are replaced.-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.apache.wicket.core.request.handler.IPartialPageRequestHandler
getComponents
-
Methods inherited from interface org.apache.wicket.request.IRequestHandler
detach, respond
-
-
-
-
Constructor Detail
-
AbstractPartialPageRequestHandler
protected AbstractPartialPageRequestHandler(Page page)
-
-
Method Detail
-
addChildren
public final void addChildren(MarkupContainer parent, Class<?> childCriteria)
Description copied from interface:IPartialPageRequestHandler
Visits all children of the specified parent container and adds them to the target if they are of same type aschildCriteria
- Specified by:
addChildren
in interfaceIPartialPageRequestHandler
- Parameters:
parent
- Must not be null.childCriteria
- Must not be null. If you want to traverse all components use ` Component.class as the value for this argument.
-
add
public final void add(Component... components)
Description copied from interface:IPartialPageRequestHandler
Adds components to the list of components to be rendered.- Specified by:
add
in interfaceIPartialPageRequestHandler
- Parameters:
components
- components to be rendered
-
getPageId
public final Integer getPageId()
Description copied from interface:IPageRequestHandler
Returns the page id.- Specified by:
getPageId
in interfaceIPageRequestHandler
- Returns:
- page id
-
getRenderCount
public final Integer getRenderCount()
Description copied from interface:IPageRequestHandler
Returns the number of times this page has been rendered.- Specified by:
getRenderCount
in interfaceIPageRequestHandler
- Returns:
- the number of times this page has been rendered.
- See Also:
IRequestablePage.getRenderCount()
-
getPageParameters
public final PageParameters getPageParameters()
- Specified by:
getPageParameters
in interfaceIPageClassRequestHandler
- Returns:
- page parameters
-
add
public final void add(Component component, String markupId)
Description copied from interface:IPartialPageRequestHandler
Adds a component to the list of components to be rendered- Specified by:
add
in interfaceIPartialPageRequestHandler
- Parameters:
component
- component to be renderedmarkupId
- id of client-side dom element that will be updated
-
prependJavaScript
public final void prependJavaScript(CharSequence javascript)
Description copied from interface:IPartialPageRequestHandler
Add JavaScript that will be evaluated on the client side before components are replaced.If the JavaScript needs to do something asynchronously (i.e. uses window.setTimeout(), for example to do animations), it may call
Wicket.Ajax.suspendCall()
to suspend the evaluation of the current Ajax call. The returned function has to be called when the asynchronous task is finished, after which the evaluation of the Ajax call is continued, e.g.target.prependJavaScript("var continueCall = Wicket.Ajax.suspendCall(); try { ... } finally { continueCall(); }");
Important: it is recommended to execute your code in try/finally to make sure the function is executed even if an error happens in your code, otherwise all following scripts and component replacements wont be made.- Specified by:
prependJavaScript
in interfaceIPartialPageRequestHandler
-
appendJavaScript
public final void appendJavaScript(CharSequence javascript)
Description copied from interface:IPartialPageRequestHandler
Add JavasSript that will be evaluated on the client side after components are replacedIf the JavaScript needs to do something asynchronously (i.e. uses window.setTimeout(), for example to do animations), it may call
Wicket.Ajax.suspendCall()
to suspend the evaluation of the current Ajax call. The returned function has to be called when the asynchronous task is finished, after which the evaluation of the Ajax call is continued, e.g.target.appendJavaScript("var continueCall = Wicket.Ajax.suspendCall(); try { ... } finally { continueCall(); }");
Important: it is recommended to execute your code in try/finally to make sure the function is executed even if an error happens in your code, otherwise all following scripts and component replacements wont be made.- Specified by:
appendJavaScript
in interfaceIPartialPageRequestHandler
-
focusComponent
public final void focusComponent(Component component)
Description copied from interface:IPartialPageRequestHandler
Sets the focus in the browser to the given component. The markup id must be set. If the component is null the focus will not be set to any component.- Specified by:
focusComponent
in interfaceIPartialPageRequestHandler
- Parameters:
component
- The component to get the focus or null.
-
isPageInstanceCreated
public final boolean isPageInstanceCreated()
Description copied from interface:IPageRequestHandler
Checks if the page instance is already created or if it will be created whenIPageRequestHandler.getPage()
is called- Specified by:
isPageInstanceCreated
in interfaceIPageRequestHandler
- Returns:
true
iff page instance is already created
-
getHeaderResponse
public final IHeaderResponse getHeaderResponse()
Description copied from interface:IPartialPageRequestHandler
Returns the header response associated with current handler. Beware that only renderOnDomReadyJavaScript and renderOnLoadJavaScript can be called outside the renderHeader(IHeaderResponse response) method. Calls to other render** methods will result in the call failing with a debug-level log statement to help you see why it failed.- Specified by:
getHeaderResponse
in interfaceIPartialPageRequestHandler
- Returns:
- header response
-
getUpdate
protected abstract PartialPageUpdate getUpdate()
-
getPage
public final Page getPage()
Description copied from interface:IPageRequestHandler
Returns the page. Be aware that the page can be instantiated if this wasn't the case already.- Specified by:
getPage
in interfaceIPageRequestHandler
- Returns:
- page instance
- See Also:
IPageRequestHandler.getPage()
-
getPageClass
public final Class<? extends IRequestablePage> getPageClass()
Description copied from interface:IPageClassRequestHandler
Returns the page class- Specified by:
getPageClass
in interfaceIPageClassRequestHandler
- Returns:
- page class
-
-