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

LinkCellRenderer

public class LinkCellRenderer extends AbstractCellRenderer

Fields Summary
protected CellRenderer
_delegateRenderer
this is the actual renderer tha will be used to display the text
protected String
_cssClass
the CSS class this link belongs to. Optional
protected String
_cssId
the id attribute this link belongs to. Optional
protected String
_link
this is the link we are setting (required)
protected String
_onclick
the (Java)script/ function to execute when the link is clicked. Optional
protected String
_ondblclick
the (Java)script/ function to execute when the link is clicked twice. Optional
protected String
_onmouseout
the (Java)script/ function to execute when cursor is away from the link. Optional
protected String
_onmouseover
the (Java)script/ function to execute when cursor is over the link. Optional
protected String
_param
if set there will be a parameter attached to link. (optional) This should be extended to allow multiple parameters
protected String
_paramValue
directly set the value for the param. Will overide paramColumn if set. optional. Either this or paramColumn must be set if param is used. Will be ignored if param not used
protected String
_target
the target frame to open in. Optional
protected String
_title
the title attribute this link belongs to. Optional
protected String
_trailParams
additional parameters after the above parameter is generated. Optional
protected int
_paramColumn
if used the param value will be taken from another column in the table. Useful if each row needs a different paramter. The paramter can be taken from a hidden cell. if paramValue is also set it will overrid this. (option either this or paramValue must be set if param is used. Will be ignored if param not used
Constructors Summary
public LinkCellRenderer()



      
    
Methods Summary
public java.lang.StringgetCellValue(org.apache.struts2.components.table.WebTable table, java.lang.Object data, int row, int col)
should the link data be encodeed?

        String value = _delegateRenderer.renderCell(table, data, row, col);

        StringBuffer cell = new StringBuffer(256);
        cell.append("<a href='").append(_link);

        if (_param != null) {
            cell.append("?").append(_param).append("=");

            if (_paramValue != null) {
                cell.append(_paramValue);
            } else if (_paramColumn >= 0) {
                cell.append(table.getModel().getValueAt(row, _paramColumn).toString());
            }
        }

        if ((_trailParams != null) && !"".equals(_trailParams)) {
            if (_param == null) {
                cell.append("?");
            } else {
                cell.append("&");
            }

            cell.append(_trailParams);
        }

        cell.append("'");

        if ((_target != null) && (!"".equals(_target))) {
            cell.append(" target='").append(_target).append("'");
        }

        if ((_cssClass != null) && (!"".equals(_cssClass))) {
            cell.append(" class='").append(_cssClass).append("'");
        }

        if ((_cssId != null) && (!"".equals(_cssId))) {
            cell.append(" id='").append(_cssId).append("'");
        }

        if ((_title != null) && (!"".equals(_title))) {
            cell.append(" title='").append(_title).append("'");
        }

        if ((_onclick != null) && (!"".equals(_onclick))) {
            cell.append(" onclick='").append(_onclick).append("'");
        }

        if ((_ondblclick != null) && (!"".equals(_ondblclick))) {
            cell.append(" ondblclick='").append(_ondblclick).append("'");
        }

        if ((_onmouseover != null) && (!"".equals(_onmouseover))) {
            cell.append(" onmouseover='").append(_onmouseover).append("'");
        }

        if ((_onmouseout != null) && (!"".equals(_onmouseout))) {
            cell.append(" onmouseout='").append(_onmouseout).append("'");
        }

        cell.append(">").append(value).append("</a>");

        return cell.toString();
    
public voidsetCssClass(java.lang.String cssClass)

        _cssClass = cssClass;
    
public voidsetCssId(java.lang.String cssId)

        _cssId = cssId;
    
public voidsetLink(java.lang.String link)

        _link = link;
    
public voidsetOnclick(java.lang.String onclick)

        _onclick = onclick;
    
public voidsetOndblclick(java.lang.String ondblclick)

        _ondblclick = ondblclick;
    
public voidsetOnmouseout(java.lang.String onmouseout)

        _onmouseout = onmouseout;
    
public voidsetOnmouseover(java.lang.String onmouseover)

        _onmouseover = onmouseover;
    
public voidsetParam(java.lang.String param)

        _param = param;
    
public voidsetParamColumn(int paramColumn)

        _paramColumn = paramColumn;
    
public voidsetParamValue(java.lang.String paramValue)

        _paramValue = paramValue;
    
public voidsetRenderer(CellRenderer delegateRenderer)
used to set the renderer to delgate to. if the render is an AbstractCellRenderer then it will take the alignment from the delegate renderer and set it that way.

        _delegateRenderer = delegateRenderer;

        if (_delegateRenderer instanceof AbstractCellRenderer) {
            setAlignment(((AbstractCellRenderer) _delegateRenderer).getAlignment());
        }
    
public voidsetTarget(java.lang.String target)

        _target = target;
    
public voidsetTitle(java.lang.String title)

        _title = title;
    
public voidsetTrailParams(java.lang.String trailParams)

        _trailParams = trailParams;