1 5 package com.opensymphony.webwork.components.table.renderer; 6 7 import com.opensymphony.webwork.components.table.WebTable; 8 9 10 14 public class LinkCellRenderer extends AbstractCellRenderer { 15 17 20 protected CellRenderer _delegateRenderer = new DefaultCellRenderer(); 21 22 25 protected String _cssClass = null; 26 27 30 protected String _cssId = null; 31 32 35 protected String _link = null; 36 37 40 protected String _onclick = null; 41 42 45 protected String _ondblclick = null; 46 47 50 protected String _onmouseout = null; 51 52 55 protected String _onmouseover = null; 56 57 61 protected String _param = null; 62 63 68 protected String _paramValue = null; 69 70 73 protected String _target = null; 74 75 78 protected String _title = null; 79 80 83 protected String _trailParams = null; 84 85 91 protected int _paramColumn = -1; 92 93 95 public LinkCellRenderer() { 96 } 97 98 100 103 public String getCellValue(WebTable table, Object data, int row, int col) { 104 String value = _delegateRenderer.renderCell(table, data, row, col); 105 106 StringBuffer cell = new StringBuffer (256); 107 cell.append("<a HREF='").append(_link); 108 109 if (_param != null) { 110 cell.append("?").append(_param).append("="); 111 112 if (_paramValue != null) { 113 cell.append(_paramValue); 114 } else if (_paramColumn >= 0) { 115 cell.append(table.getModel().getValueAt(row, _paramColumn).toString()); 116 } 117 } 118 119 if ((_trailParams != null) && !"".equals(_trailParams)) { 120 if (_param == null) { 121 cell.append("?"); 122 } else { 123 cell.append("&"); 124 } 125 126 cell.append(_trailParams); 127 } 128 129 cell.append("'"); 130 131 if ((_target != null) && (!"".equals(_target))) { 132 cell.append(" target='").append(_target).append("'"); 133 } 134 135 if ((_cssClass != null) && (!"".equals(_cssClass))) { 136 cell.append(" class='").append(_cssClass).append("'"); 137 } 138 139 if ((_cssId != null) && (!"".equals(_cssId))) { 140 cell.append(" id='").append(_cssId).append("'"); 141 } 142 143 if ((_title != null) && (!"".equals(_title))) { 144 cell.append(" title='").append(_title).append("'"); 145 } 146 147 if ((_onclick != null) && (!"".equals(_onclick))) { 148 cell.append(" onclick='").append(_onclick).append("'"); 149 } 150 151 if ((_ondblclick != null) && (!"".equals(_ondblclick))) { 152 cell.append(" ondblclick='").append(_ondblclick).append("'"); 153 } 154 155 if ((_onmouseover != null) && (!"".equals(_onmouseover))) { 156 cell.append(" onmouseover='").append(_onmouseover).append("'"); 157 } 158 159 if ((_onmouseout != null) && (!"".equals(_onmouseout))) { 160 cell.append(" onmouseout='").append(_onmouseout).append("'"); 161 } 162 163 cell.append(">").append(value).append("</a>"); 164 165 return cell.toString(); 166 } 167 168 public void setCssClass(String cssClass) { 169 _cssClass = cssClass; 170 } 171 172 public void setCssId(String cssId) { 173 _cssId = cssId; 174 } 175 176 public void setLink(String link) { 177 _link = link; 178 } 179 180 public void setOnclick(String onclick) { 181 _onclick = onclick; 182 } 183 184 public void setOndblclick(String ondblclick) { 185 _ondblclick = ondblclick; 186 } 187 188 public void setOnmouseout(String onmouseout) { 189 _onmouseout = onmouseout; 190 } 191 192 public void setOnmouseover(String onmouseover) { 193 _onmouseover = onmouseover; 194 } 195 196 public void setParam(String param) { 197 _param = param; 198 } 199 200 public void setParamColumn(int paramColumn) { 201 _paramColumn = paramColumn; 202 } 203 204 public void setParamValue(String paramValue) { 205 _paramValue = paramValue; 206 } 207 208 213 public void setRenderer(CellRenderer delegateRenderer) { 214 _delegateRenderer = delegateRenderer; 215 216 if (_delegateRenderer instanceof AbstractCellRenderer) { 217 setAlignment(((AbstractCellRenderer) _delegateRenderer).getAlignment()); 218 } 219 } 220 221 public void setTarget(String target) { 222 _target = target; 223 } 224 225 public void setTitle(String title) { 226 _title = title; 227 } 228 229 public void setTrailParams(String trailParams) { 230 _trailParams = trailParams; 231 } 232 } 233 | Popular Tags |