FileDocCategorySizeDatePackage
AbstractCellRenderer.javaAPI DocExample2515Mon Jul 23 13:26:34 BST 2007org.apache.struts2.components.table.renderer

AbstractCellRenderer

public abstract class AbstractCellRenderer extends Object implements CellRenderer
this is the base class that most renderers will be derived from. It allows setting the alignment. Subclasses should set there actuall content by implementing getCellValue

Fields Summary
protected String
_alignment
used for horizontal cell alignmnet
Constructors Summary
Methods Summary
public java.lang.StringgetAlignment()

        return _alignment;
    
protected abstract java.lang.StringgetCellValue(org.apache.struts2.components.table.WebTable table, java.lang.Object data, int row, int col)
this is the method that subclasses need to implement to set their value. they should not override renderCell unless they want to change the alignmnent renderering

protected booleanisAligned()

        return _alignment != null;
    
public java.lang.StringrenderCell(org.apache.struts2.components.table.WebTable table, java.lang.Object data, int row, int col)
implememnts CellRenderer renderCell. It sets the alignment. gets the actual data from getCellValue

        if (isAligned()) {
            StringBuffer buf = new StringBuffer(256);
            buf.append("<div align='").append(_alignment).append("'>");
            buf.append(getCellValue(table, data, row, col));
            buf.append("</div>");

            return buf.toString();
        }

        return getCellValue(table, data, row, col);
    
public voidsetAlignment(java.lang.String alignment)



        
        _alignment = alignment;