001 /** 002 * Copyright 2005-2013 The Kuali Foundation 003 * 004 * Licensed under the Educational Community License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.opensource.org/licenses/ecl2.php 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 package org.kuali.rice.krad.uif.element; 017 018 import org.kuali.rice.krad.datadictionary.parse.BeanTag; 019 import org.kuali.rice.krad.datadictionary.parse.BeanTagAttribute; 020 import org.kuali.rice.krad.uif.component.Component; 021 import org.kuali.rice.krad.uif.widget.RichTable; 022 023 import java.util.List; 024 import java.util.Set; 025 026 /** 027 * Content element that renders a table using the {@link RichTable} widget configured with an Ajax (or Javascript) 028 * data source 029 * 030 * <p> 031 * Note this is different from the table layout manager in that it does not render nested components. The data is 032 * provided directly to the rich table widget which will create the table rows (unlike the table layout which creates 033 * the table from components then invokes the table plugin to decorate). Therefore this component just creates a table 034 * element tag and invokes the rich table script 035 * </p> 036 * 037 * <p> 038 * Nested HTML can be given through the rich table data. However generally this will be read-only data with possibly 039 * some inquiry links 040 * </p> 041 * 042 * @author Kuali Rice Team (rice.collab@kuali.org) 043 */ 044 @BeanTag(name = "dataTable-bean", parent = "Uif-DataTable") 045 public class DataTable extends ContentElementBase { 046 private static final long serialVersionUID = 6201998559169962349L; 047 048 private RichTable richTable; 049 050 public DataTable() { 051 super(); 052 } 053 054 /** 055 * @see org.kuali.rice.krad.uif.component.Component#getComponentsForLifecycle() 056 */ 057 @Override 058 public List<Component> getComponentsForLifecycle() { 059 List<Component> components = super.getComponentsForLifecycle(); 060 061 components.add(richTable); 062 063 return components; 064 } 065 066 /** 067 * Widget that will render the data table client side 068 * 069 * @return RichTable instance 070 */ 071 @BeanTagAttribute(name = "richTable", type = BeanTagAttribute.AttributeType.SINGLEBEAN) 072 public RichTable getRichTable() { 073 return richTable; 074 } 075 076 /** 077 * Setter for the rich table widget 078 * 079 * @param richTable 080 */ 081 public void setRichTable(RichTable richTable) { 082 this.richTable = richTable; 083 } 084 085 /** 086 * @see org.kuali.rice.krad.uif.widget.RichTable#getAjaxSource() 087 */ 088 @BeanTagAttribute(name = "ajaxSource") 089 public String getAjaxSource() { 090 if (richTable != null) { 091 return richTable.getAjaxSource(); 092 } 093 094 return null; 095 } 096 097 /** 098 * @see org.kuali.rice.krad.uif.widget.RichTable#setAjaxSource(java.lang.String) 099 */ 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 }