|
|||||||||||||||||||
30 day Evaluation Version distributed via the Maven Jar Repository. Clover is not free. You have 30 days to evaluate it. Please visit http://www.thecortex.net/clover to obtain a licensed version of Clover | |||||||||||||||||||
Source file | Conditionals | Statements | Methods | TOTAL | |||||||||||||||
TableFormPages.java | 0% | 0% | 0% | 0% |
|
1 |
// Copyright 2004, 2005 The Apache Software Foundation
|
|
2 |
//
|
|
3 |
// Licensed under the Apache License, Version 2.0 (the "License");
|
|
4 |
// you may not use this file except in compliance with the License.
|
|
5 |
// You may obtain a copy of the License at
|
|
6 |
//
|
|
7 |
// http://www.apache.org/licenses/LICENSE-2.0
|
|
8 |
//
|
|
9 |
// Unless required by applicable law or agreed to in writing, software
|
|
10 |
// distributed under the License is distributed on an "AS IS" BASIS,
|
|
11 |
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
12 |
// See the License for the specific language governing permissions and
|
|
13 |
// limitations under the License.
|
|
14 |
|
|
15 |
package org.apache.tapestry.contrib.table.components;
|
|
16 |
|
|
17 |
import org.apache.tapestry.IRequestCycle;
|
|
18 |
import org.apache.tapestry.contrib.table.model.ITableModelSource;
|
|
19 |
import org.apache.tapestry.event.PageBeginRenderListener;
|
|
20 |
import org.apache.tapestry.event.PageDetachListener;
|
|
21 |
import org.apache.tapestry.event.PageEvent;
|
|
22 |
|
|
23 |
/**
|
|
24 |
* A low level Table component that renders the pages in the table.
|
|
25 |
*
|
|
26 |
* This component is a variant of {@link org.apache.tapestry.contrib.table.components.TablePages},
|
|
27 |
* but is designed for operation in a form. The necessary page data is stored
|
|
28 |
* in hidden fields, so that no StaleLink exceptions occur during a rewind.
|
|
29 |
* The links also submit the form, which ensures that the data in the other
|
|
30 |
* form fields is preserved even when the page chages.
|
|
31 |
*
|
|
32 |
* The component must be wrapped by {@link org.apache.tapestry.contrib.table.components.TableView}.
|
|
33 |
* <p>
|
|
34 |
* The component generates a list of pages in the Table centered around the
|
|
35 |
* current one and allows you to navigate to other pages.
|
|
36 |
* <p>
|
|
37 |
* Please see the Component Reference for details on how to use this component.
|
|
38 |
*
|
|
39 |
* [<a href="../../../../../../../ComponentReference/contrib.TableFormPages.html">Component Reference</a>]
|
|
40 |
*
|
|
41 |
* @author mindbridge
|
|
42 |
*
|
|
43 |
*/
|
|
44 |
public abstract class TableFormPages extends TablePages |
|
45 |
implements PageDetachListener, PageBeginRenderListener
|
|
46 |
{ |
|
47 |
private int m_nCurrentPage; |
|
48 |
private int m_nPageCount; |
|
49 |
private int m_nStartPage; |
|
50 |
private int m_nStopPage; |
|
51 |
|
|
52 | 0 |
public TableFormPages()
|
53 |
{ |
|
54 | 0 |
initialize(); |
55 |
} |
|
56 |
|
|
57 |
/**
|
|
58 |
* @see org.apache.tapestry.event.PageDetachListener#pageDetached(org.apache.tapestry.event.PageEvent)
|
|
59 |
*/
|
|
60 | 0 |
public void pageDetached(PageEvent event) |
61 |
{ |
|
62 | 0 |
initialize(); |
63 |
} |
|
64 |
|
|
65 |
/**
|
|
66 |
* @see org.apache.tapestry.event.PageRenderListener#pageBeginRender(org.apache.tapestry.event.PageEvent)
|
|
67 |
*/
|
|
68 | 0 |
public void pageBeginRender(PageEvent event) |
69 |
{ |
|
70 |
// values set during rewind are removed
|
|
71 | 0 |
initialize(); |
72 |
} |
|
73 |
|
|
74 |
/**
|
|
75 |
* Initialize the values and return the object to operation identical
|
|
76 |
* to that of the super class.
|
|
77 |
*/
|
|
78 | 0 |
private void initialize() |
79 |
{ |
|
80 | 0 |
m_nCurrentPage = -1; |
81 | 0 |
m_nPageCount = -1; |
82 | 0 |
m_nStartPage = -1; |
83 | 0 |
m_nStopPage = -1; |
84 |
} |
|
85 |
|
|
86 |
// This would ideally be a delayed invocation -- called after the form rewind
|
|
87 | 0 |
public void changePage(IRequestCycle objCycle) |
88 |
{ |
|
89 | 0 |
ITableModelSource objSource = getTableModelSource(); |
90 | 0 |
setCurrentPage(objSource, getSelectedPage()); |
91 |
|
|
92 |
// ensure that the change is saved
|
|
93 | 0 |
objSource.fireObservedStateChange(); |
94 |
} |
|
95 |
|
|
96 |
// defined in the JWC file
|
|
97 |
public abstract int getSelectedPage(); |
|
98 |
|
|
99 |
|
|
100 |
/**
|
|
101 |
* @return the current page
|
|
102 |
*/
|
|
103 | 0 |
public int getCurrentPage() |
104 |
{ |
|
105 | 0 |
if (m_nCurrentPage < 0)
|
106 | 0 |
m_nCurrentPage = super.getCurrentPage();
|
107 | 0 |
return m_nCurrentPage;
|
108 |
} |
|
109 |
|
|
110 |
/**
|
|
111 |
* @return number of all pages to display
|
|
112 |
*/
|
|
113 | 0 |
public int getPageCount() |
114 |
{ |
|
115 | 0 |
if (m_nPageCount < 0)
|
116 | 0 |
m_nPageCount = super.getPageCount();
|
117 | 0 |
return m_nPageCount;
|
118 |
} |
|
119 |
|
|
120 |
/**
|
|
121 |
* @return the first page to display
|
|
122 |
*/
|
|
123 | 0 |
public int getStartPage() |
124 |
{ |
|
125 | 0 |
if (m_nStartPage < 0)
|
126 | 0 |
m_nStartPage = super.getStartPage();
|
127 | 0 |
return m_nStartPage;
|
128 |
} |
|
129 |
|
|
130 |
/**
|
|
131 |
* @return the last page to display
|
|
132 |
*/
|
|
133 | 0 |
public int getStopPage() |
134 |
{ |
|
135 | 0 |
if (m_nStopPage < 0)
|
136 | 0 |
m_nStopPage = super.getStopPage();
|
137 | 0 |
return m_nStopPage;
|
138 |
} |
|
139 |
|
|
140 |
/**
|
|
141 |
* @param i the current page
|
|
142 |
*/
|
|
143 | 0 |
public void setCurrentPage(int i) |
144 |
{ |
|
145 | 0 |
m_nCurrentPage = i; |
146 |
} |
|
147 |
|
|
148 |
/**
|
|
149 |
* @param i number of all pages to display
|
|
150 |
*/
|
|
151 | 0 |
public void setPageCount(int i) |
152 |
{ |
|
153 | 0 |
m_nPageCount = i; |
154 |
} |
|
155 |
|
|
156 |
/**
|
|
157 |
* @param i the first page to display
|
|
158 |
*/
|
|
159 | 0 |
public void setStartPage(int i) |
160 |
{ |
|
161 | 0 |
m_nStartPage = i; |
162 |
} |
|
163 |
|
|
164 |
/**
|
|
165 |
* @param i the last page to display
|
|
166 |
*/
|
|
167 | 0 |
public void setStopPage(int i) |
168 |
{ |
|
169 | 0 |
m_nStopPage = i; |
170 |
} |
|
171 |
|
|
172 |
} |
|
173 |
|
|