1 12 package org.displaytag.decorator; 13 14 import javax.servlet.jsp.PageContext ; 15 16 import org.displaytag.exception.ObjectLookupException; 17 import org.displaytag.model.TableModel; 18 import org.displaytag.render.TableWriterTemplate; 19 import org.displaytag.util.LookupUtil; 20 import org.displaytag.util.TagConstants; 21 22 23 28 public abstract class TableDecorator extends Decorator 29 { 30 31 34 private Object currentRowObject; 35 36 39 private int viewIndex = -1; 40 41 44 private int listIndex = -1; 45 46 49 protected TableModel tableModel; 50 51 55 public final int getViewIndex() 56 { 57 return this.viewIndex; 58 } 59 60 65 public final int getListIndex() 66 { 67 return this.listIndex; 68 } 69 70 74 public final Object getCurrentRowObject() 75 { 76 return this.currentRowObject; 77 } 78 79 85 public void init(PageContext context, Object decorated, TableModel tableModel) 86 { 87 this.tableModel = tableModel; 88 this.init(context, decorated); 89 } 90 91 99 public final void initRow(Object rowObject, int currentViewIndex, int currentListIndex) 100 { 101 this.currentRowObject = rowObject; 102 this.viewIndex = currentViewIndex; 103 this.listIndex = currentListIndex; 104 } 105 106 110 public String startRow() 111 { 112 return null; 113 } 114 115 119 public String finishRow() 120 { 121 return null; 122 } 123 124 128 public void finish() 129 { 130 this.currentRowObject = null; 131 super.finish(); 132 } 133 134 139 public String addRowClass() 140 { 141 return null; 142 } 143 144 149 public String addRowId() 150 { 151 return null; 152 } 153 154 159 public void startOfGroup(String value, int group) 160 { 161 } 162 163 168 public void endOfGroup(String value, int groupThatHasEnded) 169 { 170 } 171 172 179 public String displayGroupedValue(String cellValue, short groupingStatus) 180 { 181 if (groupingStatus == TableWriterTemplate.GROUP_END || groupingStatus == TableWriterTemplate.GROUP_NO_CHANGE) 182 { 183 return TagConstants.EMPTY_STRING; 184 } 185 else 186 { 187 return cellValue; 188 } 189 } 190 191 public boolean isLastRow() 192 { 193 return getListIndex() == this.tableModel.getRowListPage().size() - 1; 194 } 195 196 202 protected Object evaluate(String propertyName) 203 { 204 try 205 { 206 return LookupUtil.getBeanProperty(getCurrentRowObject(), propertyName); 207 } 208 catch (ObjectLookupException e) 209 { 210 return null; 211 } 212 } 213 214 } | Popular Tags |