public class PageCallback extends java.lang.Object implements ICallback
Example usage of PageCallback:
The Home 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 Home page.
public class Home extends BasePage { public void validate(IRequestCycle cycle) { Visit visit = (Visit) getVisit(); if (!visit.isAuthenticated()) { Login login = (Login) cycle.getPage("Login"); login.setCallback(new PageCallback(this)); throw new PageRedirectException(login); } } } 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); } } }
Constructor and Description |
---|
PageCallback(IPage page) |
PageCallback(java.lang.String pageName) |
Modifier and Type | Method and Description |
---|---|
void |
performCallback(IRequestCycle cycle)
Invokes
IRequestCycle.activate(String) to select the previously identified page as
the response page. |
java.lang.String |
toString() |
public PageCallback(java.lang.String pageName)
public PageCallback(IPage page)
public java.lang.String toString()
toString
in class java.lang.Object
public void performCallback(IRequestCycle cycle)
IRequestCycle.activate(String)
to select the previously identified page as
the response page.performCallback
in interface ICallback