|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.apache.tapestry.callback.ExternalCallback
A callback for returning to an 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 Form| Constructor Summary | |
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. |
|
| Method Summary | |
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()
|
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public ExternalCallback(java.lang.String pageName,
java.lang.Object[] parameters)
public ExternalCallback(IExternalPage page,
java.lang.Object[] parameters)
| Method Detail |
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 ICallbackpublic java.lang.String toString()
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||