KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > tapestry > pets > presentation > components > Border


1 package org.apache.tapestry.pets.presentation.components;
2
3 import org.apache.tapestry.BaseComponent;
4 import org.apache.tapestry.IRequestCycle;
5 import org.apache.tapestry.event.PageEvent;
6 import org.apache.tapestry.event.PageRenderListener;
7 import org.apache.tapestry.pets.Visit;
8 import org.apache.tapestry.pets.presentation.pages.CategoryPage;
9 import org.apache.tapestry.pets.presentation.pages.EditAccountPage;
10 import org.apache.tapestry.pets.presentation.pages.SearchPage;
11
12 public abstract class Border extends BaseComponent implements PageRenderListener
13 {
14     public void pageBeginRender(PageEvent event)
15     {
16         // Check if the user is at the HomePage
17
String JavaDoc homePage = "Home";
18         setShowSubMenu(!(this.getPage().getPageName().equals(homePage)));
19         
20         // Get the visit, if it exists, without creating it.
21
Visit visit = (Visit) getPage().getEngine().getVisit();
22         if (visit == null)
23         {
24             setLoggedIn(false);
25             setShowBanner(false);
26             setFavoriteCategory(null);
27         }
28         else
29         {
30             setLoggedIn(visit.isUserLoggedIn());
31             setShowBanner(visit.getBannerOptions() && getShowSubMenu());
32             setFavoriteCategory(visit.getFavoriteCategory());
33         }
34     }
35
36     public void directCategory(IRequestCycle cycle)
37     {
38         Object JavaDoc[] parameters = cycle.getServiceParameters();
39         String JavaDoc categoryToShow = ((String JavaDoc) parameters[0]).toString();
40         CategoryPage category = (CategoryPage) cycle.getPage("Category");
41         category.setCategory(categoryToShow);
42         cycle.activate(category);
43     }
44
45     public void directSearch(IRequestCycle cycle)
46     {
47         SearchPage search = (SearchPage) cycle.getPage("Search");
48         search.setSearchWord(getSearchWord());
49         cycle.activate(search);
50     }
51
52     public void directEditAccount(IRequestCycle cycle)
53     {
54         EditAccountPage editaccount = (EditAccountPage) cycle.getPage("EditAccount");
55         cycle.activate(editaccount);
56     }
57     public abstract String JavaDoc getFavoriteCategory();
58
59     public abstract boolean getLoggedIn();
60
61     public abstract String JavaDoc getSearchWord();
62
63     public abstract boolean getShowBanner();
64
65     public abstract boolean getShowSubMenu();
66
67     public abstract void setFavoriteCategory(String JavaDoc string);
68
69     public abstract void setLoggedIn(boolean b);
70
71     public abstract void setSearchWord(String JavaDoc string);
72
73     public abstract void setShowBanner(boolean b);
74
75     public abstract void setShowSubMenu(boolean b);
76
77 }
78
Popular Tags