public class ExternalCallback extends java.lang.Object implements ICallback
IExternalPage
.
Example usage of ExternalCallback:
The External page ensure a user is authenticated in the
IPage.validate(IRequestCycle)
method. If the user is not
authenticated, they are redirected to the Login page, after setting a callback in the Login page.
The Login page formSubmit() IActionListener
authenticates
the user and then invokes ICallback.performCallback(IRequestCycle)
to the External page.
public class External extends BasePage implements IExternalPage { private Integer _itemId; public void validate(IRequestCycle cycle) throws RequestCycleException { Visit visit = (Visit) getVisit(); if (!visit.isAuthenticated()) { Login login = (Login) cycle.getPage("Login"); login.setCallback (new ExternalCallback(this, cycle.getServiceParameters())); throw new PageRedirectException(login); } } public void activateExternalPage(Object[] params, IRequestCycle cycle) throws RequestCycleException { _itemId = (Integer) params[0]; } } public Login extends BasePage { private ICallback _callback; public void setCallback(ICallback _callback) { _callback = callback; } public void formSubmit(IRequestCycle cycle) { // Authentication code .. Visit visit = (Visit) getVisit(); visit.setAuthenticated(true); if (_callback != null) { _callback.performCallback(cycle); } } }
IExternalPage
,
ExternalService
,
Serialized FormConstructor and Description |
---|
ExternalCallback(IExternalPage page,
java.lang.Object[] parameters)
Creates a new ExternalCallback for the page.
|
ExternalCallback(java.lang.String pageName,
java.lang.Object[] parameters)
Creates a new ExternalCallback for the named IExternalPage.
|
Modifier and Type | Method and Description |
---|---|
void |
performCallback(IRequestCycle cycle)
Invokes
IRequestCycle#setPage(String) to select the previously identified
IExternalPage as the response page and activates the page by invoking
activateExternalPage() with the callback parameters and request cycle. |
java.lang.String |
toString() |
public ExternalCallback(java.lang.String pageName, java.lang.Object[] parameters)
public ExternalCallback(IExternalPage page, java.lang.Object[] parameters)
public void performCallback(IRequestCycle cycle)
IRequestCycle#setPage(String)
to select the previously identified
IExternalPage as the response page and activates the page by invoking
activateExternalPage() with the callback parameters and request cycle.performCallback
in interface ICallback
public java.lang.String toString()
toString
in class java.lang.Object