1 /**
2 * Copyright 2005-2013 The Kuali Foundation
3 *
4 * Licensed under the Educational Community License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.opensource.org/licenses/ecl2.php
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package org.kuali.rice.krad.uif.element;
17
18 import org.kuali.rice.krad.datadictionary.parse.BeanTag;
19 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute;
20 import org.kuali.rice.krad.uif.component.Component;
21 import org.kuali.rice.krad.uif.widget.RichTable;
22
23 import java.util.List;
24 import java.util.Set;
25
26 /**
27 * Content element that renders a table using the {@link RichTable} widget configured with an Ajax (or Javascript)
28 * data source
29 *
30 * <p>
31 * Note this is different from the table layout manager in that it does not render nested components. The data is
32 * provided directly to the rich table widget which will create the table rows (unlike the table layout which creates
33 * the table from components then invokes the table plugin to decorate). Therefore this component just creates a table
34 * element tag and invokes the rich table script
35 * </p>
36 *
37 * <p>
38 * Nested HTML can be given through the rich table data. However generally this will be read-only data with possibly
39 * some inquiry links
40 * </p>
41 *
42 * @author Kuali Rice Team (rice.collab@kuali.org)
43 */
44 @BeanTag(name = "dataTable-bean", parent = "Uif-DataTable")
45 public class DataTable extends ContentElementBase {
46 private static final long serialVersionUID = 6201998559169962349L;
47
48 private RichTable richTable;
49
50 public DataTable() {
51 super();
52 }
53
54 /**
55 * @see org.kuali.rice.krad.uif.component.Component#getComponentsForLifecycle()
56 */
57 @Override
58 public List<Component> getComponentsForLifecycle() {
59 List<Component> components = super.getComponentsForLifecycle();
60
61 components.add(richTable);
62
63 return components;
64 }
65
66 /**
67 * Widget that will render the data table client side
68 *
69 * @return RichTable instance
70 */
71 @BeanTagAttribute(name = "richTable", type = BeanTagAttribute.AttributeType.SINGLEBEAN)
72 public RichTable getRichTable() {
73 return richTable;
74 }
75
76 /**
77 * Setter for the rich table widget
78 *
79 * @param richTable
80 */
81 public void setRichTable(RichTable richTable) {
82 this.richTable = richTable;
83 }
84
85 /**
86 * @see org.kuali.rice.krad.uif.widget.RichTable#getAjaxSource()
87 */
88 @BeanTagAttribute(name = "ajaxSource")
89 public String getAjaxSource() {
90 if (richTable != null) {
91 return richTable.getAjaxSource();
92 }
93
94 return null;
95 }
96
97 /**
98 * @see org.kuali.rice.krad.uif.widget.RichTable#setAjaxSource(java.lang.String)
99 */
100 public void setAjaxSource(String ajaxSource) {
101 if (richTable != null) {
102 richTable.setAjaxSource(ajaxSource);
103 }
104 }
105
106 /**
107 * @see org.kuali.rice.krad.uif.widget.RichTable#getHiddenColumns()
108 */
109 @BeanTagAttribute(name = "hiddenColumns", type = BeanTagAttribute.AttributeType.SETVALUE)
110 public Set<String> getHiddenColumns() {
111 if (richTable != null) {
112 return richTable.getHiddenColumns();
113 }
114
115 return null;
116 }
117
118 /**
119 * @see org.kuali.rice.krad.uif.widget.RichTable#setHiddenColumns(java.util.Set<java.lang.String>)
120 */
121 public void setHiddenColumns(Set<String> hiddenColumns) {
122 if (richTable != null) {
123 richTable.setHiddenColumns(hiddenColumns);
124 }
125 }
126
127 /**
128 * @see org.kuali.rice.krad.uif.widget.RichTable#getSortableColumns()
129 */
130 @BeanTagAttribute(name = "sortableColumns", type = BeanTagAttribute.AttributeType.SETVALUE)
131 public Set<String> getSortableColumns() {
132 if (richTable != null) {
133 return richTable.getSortableColumns();
134 }
135
136 return null;
137 }
138
139 /**
140 * @see org.kuali.rice.krad.uif.widget.RichTable#setSortableColumns(java.util.Set<java.lang.String>)
141 */
142 public void setSortableColumns(Set<String> sortableColumns) {
143 if (richTable != null) {
144 richTable.setSortableColumns(sortableColumns);
145 }
146 }
147
148 /**
149 * @see org.kuali.rice.krad.uif.component.ComponentBase#copy()
150 */
151 @Override
152 protected <T> void copyProperties(T component) {
153 super.copyProperties(component);
154 DataTable dataTableCopy = (DataTable) component;
155
156 if (this.richTable != null) {
157 dataTableCopy.setRichTable((RichTable) this.richTable.copy());
158 }
159 }
160 }