01: package net.xoetrope.builder;
02:
03: import net.xoetrope.xui.XPage;
04: import net.xoetrope.xui.XPageManager;
05: import net.xoetrope.xui.XProjectManager;
06:
07: /**
08: * NavigationHelper extends XPage by adding a few simple methods to assist in
09: * navigating from page to page. The previous and next methods assume that
10: * the names of the next and previous pages have been added as attributes
11: * to the page.
12: * <p>Copyright: Copyright (c) Xoetrope Ltd., 2002-2003</p>
13: * License: see license.txt
14: */
15: public class NavigationHelper extends XPage {
16: protected XPageManager pageManager;
17:
18: public NavigationHelper() {
19: pageManager = XProjectManager.getPageManager();
20: }
21:
22: /**
23: * Navigate to the page referenced by the 'home' attribute
24: */
25: public void homePage() {
26: if (wasMouseClicked())
27: navigateToPage("home");
28: }
29:
30: /**
31: * Navigate to the previous page in the page display history
32: */
33: public void prevPage() {
34: if (wasMouseClicked())
35: XProjectManager.getPageManager().showPrevious();
36: }
37:
38: /**
39: * Navigate to the page referenced by the 'next' attribute
40: */
41: public void nextPage() {
42: if (wasMouseClicked())
43: navigateToPage("next");
44: }
45:
46: /**
47: * Lookup the key/attribute and navigate to that page.
48: */
49: protected void navigateToPage(String key) {
50: String dest = (String) getAttribute(key);
51: if (dest != null)
52: XProjectManager.getPageManager().showPage(dest);
53: }
54: }
|