KickJava   Java API By Example, From Geeks To Geeks.

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


1 package org.apache.tapestry.pets.presentation.components;
2
3 import org.apache.tapestry.BaseComponent;
4 import org.apache.tapestry.IBinding;
5 import org.apache.tapestry.IMarkupWriter;
6 import org.apache.tapestry.IRequestCycle;
7 import org.apache.tapestry.event.PageDetachListener;
8 import org.apache.tapestry.event.PageEvent;
9
10 public class NavBar extends BaseComponent implements PageDetachListener
11 {
12     private boolean showNextLink;
13     private boolean showPreviousLink;
14     private PagedModel pagedModel;
15     private IBinding _pagedModelBinding;
16
17     //private int pageCount;
18
private String JavaDoc stateKey;
19     private String JavaDoc listenerName;
20
21     public void pageDetached(PageEvent event)
22     {
23         showNextLink = false;
24         showPreviousLink = false;
25     }
26
27     public void finishLoad()
28     {
29         getPage().addPageDetachListener(this);
30         super.finishLoad();
31     }
32
33     protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle)
34     {
35         pagedModel = (PagedModel) _pagedModelBinding.getObject("pagedModel", PagedModel.class);
36         super.renderComponent(writer, cycle);
37     }
38
39     public IBinding getPagedModelBinding()
40     {
41         return _pagedModelBinding;
42     }
43
44     public void setPagedModelBinding(IBinding pagedModelBinding)
45     {
46         _pagedModelBinding = pagedModelBinding;
47     }
48
49     public boolean getShowPreviousLink()
50     {
51         return pagedModel.getHasPreviousPage();
52     }
53
54     public boolean getShowNextLink()
55     {
56         return pagedModel.getHasNextPage();
57     }
58
59     public int getCurrentPage()
60     {
61         return pagedModel.getPageToShow();
62     }
63
64     public int getPageCount()
65     {
66         return pagedModel.getPageCount();
67     }
68
69     public String JavaDoc getStateKey()
70     {
71         return (stateKey == null) ? "" : stateKey;
72     }
73
74     public void setStateKey(String JavaDoc stateKey)
75     {
76         this.stateKey = stateKey;
77     }
78
79     public String JavaDoc getListenerName()
80     {
81         return listenerName;
82     }
83
84     public void setListenerName(String JavaDoc listenerName)
85     {
86         this.listenerName = listenerName;
87     }
88 }
89
Popular Tags