Package org.apache.wicket.ajax
Class AjaxNewWindowNotifyingBehavior
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.behavior.AbstractAjaxBehavior
-
- org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
-
- org.apache.wicket.ajax.AjaxNewWindowNotifyingBehavior
-
- All Implemented Interfaces:
Serializable
,IComponentAwareEventSink
,IRequestListener
,IComponentAwareHeaderContributor
,IClusterable
public class AjaxNewWindowNotifyingBehavior extends AbstractDefaultAjaxBehavior
An Ajax behavior that notifies when a new browser window/tab is opened with url to a page instance which is already opened in another window/tab in the same user session.- Since:
- 6.0
- See Also:
onNewWindow(AjaxRequestTarget)
, Serialized Form
-
-
Field Summary
-
Fields inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
INDICATOR
-
-
Constructor Summary
Constructors Constructor Description AjaxNewWindowNotifyingBehavior()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getWindowName()
Returns the window's name.protected String
newWindowName()
Create a name for a nameless window, default uses a randomUUID
.protected void
onNewWindow(AjaxRequestTarget target)
A callback method that is called when a new window/tab is opened for a page instance which is already opened in another window/tab.static AjaxNewWindowNotifyingBehavior
onNewWindow(org.danekja.java.util.function.serializable.SerializableConsumer<AjaxRequestTarget> onNewWindow)
Creates anAjaxNewWindowNotifyingBehavior
based on lambda expressionsvoid
renderHead(Component component, IHeaderResponse response)
Overridden to initiate a request once the page was rendered.protected void
respond(AjaxRequestTarget target)
protected void
updateAjaxAttributes(AjaxRequestAttributes attributes)
Overridden to add the current window name to the request.-
Methods inherited from class org.apache.wicket.ajax.AbstractDefaultAjaxBehavior
findIndicatorId, getAttributes, getCallbackFunction, getCallbackFunctionBody, getCallbackScript, getCallbackScript, onBind, onMethodMismatch, onRequest, postprocessConfiguration, renderAjaxAttributes, renderAjaxAttributes
-
Methods inherited from class org.apache.wicket.behavior.AbstractAjaxBehavior
afterRender, bind, getCallbackUrl, getComponent, onComponentRendered, onComponentTag, onComponentTag, onUnbind, unbind
-
Methods inherited from class org.apache.wicket.behavior.Behavior
beforeRender, canCallListener, detach, getStatelessHint, isEnabled, isTemporary, onAttribute, onConfigure, onEvent, onException, onRemove, onTag
-
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.IRequestListener
rendersPage
-
-
-
-
Constructor Detail
-
AjaxNewWindowNotifyingBehavior
public AjaxNewWindowNotifyingBehavior()
-
-
Method Detail
-
getWindowName
public String getWindowName()
Returns the window's name.- Returns:
- name of
null
if not yet bound to a window
-
updateAjaxAttributes
protected void updateAjaxAttributes(AjaxRequestAttributes attributes)
Overridden to add the current window name to the request.- Overrides:
updateAjaxAttributes
in classAbstractDefaultAjaxBehavior
-
renderHead
public void renderHead(Component component, IHeaderResponse response)
Overridden to initiate a request once the page was rendered.- Specified by:
renderHead
in interfaceIComponentAwareHeaderContributor
- Overrides:
renderHead
in classAbstractDefaultAjaxBehavior
- Parameters:
component
- component which is contributing to the response. This parameter is here to give the component as the context for component-awares implementing this interfaceresponse
- Response object- See Also:
Behavior.renderHead(Component, org.apache.wicket.markup.head.IHeaderResponse)
-
respond
protected void respond(AjaxRequestTarget target)
- Specified by:
respond
in classAbstractDefaultAjaxBehavior
- Parameters:
target
- The AJAX target
-
newWindowName
protected String newWindowName()
Create a name for a nameless window, default uses a randomUUID
.- Returns:
- window name
-
onNewWindow
protected void onNewWindow(AjaxRequestTarget target)
A callback method that is called when a new window/tab is opened for a page instance which is already opened in another window/tab.Default implementation redirects to a new page instance with identical page parameters.
- Parameters:
target
- the current request handler
-
onNewWindow
public static AjaxNewWindowNotifyingBehavior onNewWindow(org.danekja.java.util.function.serializable.SerializableConsumer<AjaxRequestTarget> onNewWindow)
Creates anAjaxNewWindowNotifyingBehavior
based on lambda expressions- Parameters:
onNewWindow
- theSerializableConsumer
which accepts theAjaxRequestTarget
- Returns:
- the
AjaxNewWindowNotifyingBehavior
-
-