1 5 package com.opensymphony.webwork.components.table.renderer; 6 7 import com.opensymphony.webwork.components.table.WebTable; 8 9 10 15 abstract public class AbstractCellRenderer implements CellRenderer { 16 18 21 protected String _alignment = null; 22 23 25 public void setAlignment(String alignment) { 26 _alignment = alignment; 27 } 28 29 public String getAlignment() { 30 return _alignment; 31 } 32 33 37 public String renderCell(WebTable table, Object data, int row, int col) { 38 if (isAligned()) { 39 StringBuffer buf = new StringBuffer (256); 40 buf.append("<div align='").append(_alignment).append("'>"); 41 buf.append(getCellValue(table, data, row, col)); 42 buf.append("</div>"); 43 44 return buf.toString(); 45 } 46 47 return getCellValue(table, data, row, col); 48 } 49 50 protected boolean isAligned() { 51 return _alignment != null; 52 } 53 54 59 abstract protected String getCellValue(WebTable table, Object data, int row, int col); 60 } 61 | Popular Tags |