org.apache.tapestry.callback
Class ExternalCallback
java.lang.Object
|
+--org.apache.tapestry.callback.ExternalCallback
- All Implemented Interfaces:
- ICallback, Serializable
- public class ExternalCallback
- extends Object
- implements ICallback
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);
}
}
}
- Since:
- 2.3
- Version:
- $Id: ExternalCallback.java,v 1.5 2003/05/28 13:41:44 hlship Exp $
- Author:
- Malcolm Edgar
- See Also:
IExternalPage
,
ExternalService
, Serialized Form
ExternalCallback
public ExternalCallback(String pageName,
Object[] parameters)
- Creates a new ExternalCallback for the named IExternalPage.
The parameters (which may be null) is retained, not copied.
ExternalCallback
public ExternalCallback(IExternalPage page,
Object[] parameters)
- Creates a new ExternalCallback for the page. The parameters
(which may be null) is retained, not copied.
performCallback
public 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.
- Specified by:
performCallback
in interface ICallback
toString
public String toString()
- Overrides:
toString
in class Object