KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > cayenne > tutorial > tapestry > pages > ApplicationPage


1 package cayenne.tutorial.tapestry.pages;
2
3 import org.apache.tapestry.IRequestCycle;
4 import org.apache.tapestry.engine.IPageLoader;
5 import org.apache.tapestry.event.PageEvent;
6 import org.apache.tapestry.event.PageRenderListener;
7 import org.apache.tapestry.html.BasePage;
8 import org.apache.tapestry.spec.IComponentSpecification;
9 import org.objectstyle.cayenne.access.DataContext;
10
11 import cayenne.tutorial.tapestry.Visit;
12
13 /**
14  * A superclass of all application pages. Contains utility methods
15  * to access DataContext and such.
16  *
17  * @author Andrei Adamchik
18  */

19 public class ApplicationPage extends BasePage implements PageRenderListener {
20
21     public void finishLoad(
22         IRequestCycle cycle,
23         IPageLoader loader,
24         IComponentSpecification specification) {
25
26         // will listen for its own render events
27
addPageRenderListener(this);
28         super.finishLoad(cycle, loader, specification);
29     }
30
31     /**
32      * Helper method to simplify obtaining Cayenne DataContext by subclasses.
33      */

34     protected DataContext getVisitDataContext() {
35         Visit visit = (Visit) getPage().getVisit();
36         return visit.getDataContext();
37     }
38
39     /**
40      * Implementation of PageRenderListener. In Tapestry 3.0 implementing PageRenderListener
41      * seems to be the only way to catch the last chance to reinitialize persistent variables
42      * before page rendering starts. Default implementation of this method does nothing,
43      * allowing subclasses to perform proper initialization.
44      */

45     // Is there a standard method to override instead?
46
public void pageBeginRender(PageEvent event) {
47         // do nothing...
48
}
49 }
50
Popular Tags