|
|||||||||||||||||||
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 | |||||||||||||||
TableRows.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 java.util.Iterator;
|
|
18 |
|
|
19 |
import org.apache.tapestry.IBinding;
|
|
20 |
import org.apache.tapestry.IMarkupWriter;
|
|
21 |
import org.apache.tapestry.IRequestCycle;
|
|
22 |
import org.apache.tapestry.contrib.table.model.ITableModel;
|
|
23 |
import org.apache.tapestry.contrib.table.model.ITableRowSource;
|
|
24 |
|
|
25 |
/**
|
|
26 |
* A low level Table component that generates the rows of the current page in the table.
|
|
27 |
* This component must be wrapped by {@link org.apache.tapestry.contrib.table.components.TableView}.
|
|
28 |
*
|
|
29 |
* <p>
|
|
30 |
* The component iterates over the rows of the current page in the table.
|
|
31 |
* The rows are wrapped in 'tr' tags by default.
|
|
32 |
* You can define columns manually within, or
|
|
33 |
* you can use {@link org.apache.tapestry.contrib.table.components.TableValues}
|
|
34 |
* to generate the columns automatically.
|
|
35 |
*
|
|
36 |
* <p>
|
|
37 |
* Please see the Component Reference for details on how to use this component.
|
|
38 |
*
|
|
39 |
* [<a href="../../../../../../../ComponentReference/contrib.TableRows.html">Component Reference</a>]
|
|
40 |
*
|
|
41 |
* @author mindbridge
|
|
42 |
*
|
|
43 |
*/
|
|
44 |
public abstract class TableRows extends AbstractTableViewComponent implements ITableRowSource |
|
45 |
{ |
|
46 |
|
|
47 |
// Transient
|
|
48 |
private Object m_objTableRow = null; |
|
49 |
|
|
50 |
/**
|
|
51 |
* Returns the currently rendered table row.
|
|
52 |
* You can call this method to obtain the current row.
|
|
53 |
*
|
|
54 |
* @return Object the current table row
|
|
55 |
*/
|
|
56 | 0 |
public Object getTableRow()
|
57 |
{ |
|
58 | 0 |
return m_objTableRow;
|
59 |
} |
|
60 |
|
|
61 |
/**
|
|
62 |
* Sets the currently rendered table row.
|
|
63 |
* This method is for internal use only.
|
|
64 |
*
|
|
65 |
* @param tableRow The current table row
|
|
66 |
*/
|
|
67 | 0 |
public void setTableRow(Object tableRow) |
68 |
{ |
|
69 | 0 |
m_objTableRow = tableRow; |
70 |
|
|
71 | 0 |
IBinding objRowBinding = getBinding("row");
|
72 | 0 |
if (objRowBinding != null) |
73 | 0 |
objRowBinding.setObject(tableRow); |
74 |
} |
|
75 |
|
|
76 |
/**
|
|
77 |
* Get the list of all table rows to be displayed on this page.
|
|
78 |
*
|
|
79 |
* @return an iterator of all table rows
|
|
80 |
*/
|
|
81 | 0 |
public Iterator getTableRowsIterator()
|
82 |
{ |
|
83 | 0 |
ITableModel objTableModel = getTableModelSource().getTableModel(); |
84 | 0 |
return objTableModel.getCurrentPageRows();
|
85 |
} |
|
86 |
|
|
87 |
/**
|
|
88 |
* @see org.apache.tapestry.BaseComponent#renderComponent(IMarkupWriter, IRequestCycle)
|
|
89 |
*/
|
|
90 | 0 |
protected void renderComponent(IMarkupWriter writer, IRequestCycle cycle) |
91 |
{ |
|
92 | 0 |
Object objOldValue = cycle.getAttribute(ITableRowSource.TABLE_ROW_SOURCE_ATTRIBUTE); |
93 | 0 |
cycle.setAttribute(ITableRowSource.TABLE_ROW_SOURCE_ATTRIBUTE, this);
|
94 |
|
|
95 | 0 |
super.renderComponent(writer, cycle);
|
96 |
|
|
97 | 0 |
cycle.setAttribute(ITableRowSource.TABLE_ROW_SOURCE_ATTRIBUTE, objOldValue); |
98 |
|
|
99 |
// set the current row to null when the component is not active
|
|
100 | 0 |
m_objTableRow = null;
|
101 |
} |
|
102 |
|
|
103 |
} |
|
104 |
|
|