org.apache.tapestry.callback
Class PageCallback

java.lang.Object
  extended by org.apache.tapestry.callback.PageCallback
All Implemented Interfaces:
Serializable, ICallback

public class PageCallback
extends Object
implements ICallback

Simple callback for returning to a page.

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);
          }
      }
  }    
  

Since:
0.2.9
Version:
$Id: PageCallback.java 243791 2004-02-19 17:38:13Z hlship $
Author:
Howard Lewis Ship
See Also:
Serialized Form

Constructor Summary
PageCallback(IPage page)
           
PageCallback(String pageName)
           
 
Method Summary
 void performCallback(IRequestCycle cycle)
          Invokes IRequestCycle.activate(String) to select the previously identified page as the response page.
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

PageCallback

public PageCallback(String pageName)

PageCallback

public PageCallback(IPage page)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

performCallback

public void performCallback(IRequestCycle cycle)
Invokes IRequestCycle.activate(String) to select the previously identified page as the response page.

Specified by:
performCallback in interface ICallback