001 package railo.runtime.tag; 002 003 import javax.servlet.jsp.tagext.Tag; 004 005 import railo.commons.color.ColorCaster; 006 import railo.commons.lang.StringUtil; 007 import railo.runtime.exp.ExpressionException; 008 import railo.runtime.exp.PageException; 009 import railo.runtime.exp.TagNotSupported; 010 import railo.runtime.ext.tag.TagImpl; 011 import railo.runtime.type.util.ListUtil; 012 013 /** 014 * Used with cfgrid in a cfform, you use cfgridcolumn to specify column data in a cfgrid control. Font and alignment 015 * attributes used in cfgridcolumn override any global font or alignment settings defined in cfgrid. 016 * 017 * 018 * 019 **/ 020 public final class GridColumn extends TagImpl { 021 022 private GridColumnBean column=new GridColumnBean(); 023 024 public GridColumn() throws TagNotSupported { 025 throw new TagNotSupported("GridColumn"); 026 } 027 028 private String valuesdelimiter=","; 029 private String valuesdisplay; 030 private String values; 031 032 @Override 033 public void release() { 034 column=new GridColumnBean(); 035 valuesdelimiter=","; 036 valuesdisplay=null; 037 values=null; 038 } 039 040 /** 041 * @param mask the mask to set 042 */ 043 public void setMask(String mask) { 044 column.setMask(mask); 045 } 046 047 /** set the value display 048 * Yes or No. Use to hide columns. Default is Yes to display the column. 049 * @param display value to set 050 **/ 051 public void setDisplay(boolean display) { 052 column.setDisplay(display); 053 } 054 055 /** set the value width 056 * The width of the column, in pixels. Default is the width of the column head text. 057 * @param width value to set 058 **/ 059 public void setWidth(double width) { 060 column.setWidth((int) width); 061 } 062 063 /** set the value headerfontsize 064 * Font size to use for the column header, in pixels. Default is as specified by the 065 * orresponding attribute of cfgrid. 066 * @param headerfontsize value to set 067 **/ 068 public void setHeaderfontsize(double headerfontsize) { 069 column.setHeaderFontSize((int)headerfontsize); 070 } 071 072 /** set the value hrefkey 073 * The name of a query column when the grid uses a query. The column specified becomes the Key 074 * regardless of the select mode for the grid. 075 * @param hrefkey value to set 076 **/ 077 public void setHrefkey(String hrefkey) { 078 column.setHrefKey(hrefkey); 079 } 080 081 /** set the value target 082 * The name of the frame in which to open the link specified in href. 083 * @param target value to set 084 **/ 085 public void setTarget(String target) { 086 column.setTarget(target); 087 } 088 089 /** set the value values 090 * Formats cells in the column as drop down list boxes. lets end users select an item in a drop 091 * down list. Use the values attribute to specify the items you want to appear in the drop down list. 092 * @param values value to set 093 **/ 094 public void setValues(String values) { 095 this.values=values; 096 } 097 098 /** set the value headerfont 099 * Font to use for the column header. Default is as specified by the corresponding attribute of 100 * cfgrid. 101 * @param headerfont value to set 102 **/ 103 public void setHeaderfont(String headerfont) { 104 column.setHeaderFont(headerfont); 105 } 106 107 /** set the value font 108 * Font name to use for data in the column. Defaults is the font specified by cfgrid. 109 * @param font value to set 110 **/ 111 public void setFont(String font) { 112 column.setFont(font); 113 } 114 115 /** set the value italic 116 * Yes or No. Yes displays all grid control text in italic. Default is as specified by the 117 * corresponding attribute of cfgrid. 118 * @param italic value to set 119 **/ 120 public void setItalic(boolean italic) { 121 column.setItalic(italic); 122 } 123 124 /** set the value bgcolor 125 * Color value for the background of the grid column, or an expression you can use to manipulate grid 126 * column background color. Valid color entries are: black, magenta, cyan, orange, darkgray, pink, gray, 127 * white (default), lightgray, yellow. 128 * @param bgcolor value to set 129 * @throws ExpressionException 130 **/ 131 public void setBgcolor(String bgcolor) throws ExpressionException { 132 column.setBgColor(ColorCaster.toColor(bgcolor)); 133 } 134 135 /** set the value valuesdisplay 136 * Used to map elements specified in the values attribute to a string of your choice to display 137 * in the drop down list. Enter comma separated strings and/or numeric range(s). 138 * @param valuesdisplay value to set 139 **/ 140 public void setValuesdisplay(String valuesdisplay) { 141 this.valuesdisplay=valuesdisplay; 142 } 143 144 /** set the value headeritalic 145 * Yes or No. Yes displays column header text in italic. Default is as specified by the 146 * corresponding attribute of cfgrid. 147 * @param headeritalic value to set 148 **/ 149 public void setHeaderitalic(boolean headeritalic) { 150 column.setHeaderItalic(headeritalic); 151 } 152 153 /** set the value name 154 * A name for the grid column element. If the grid uses a query, the column name must specify the 155 * name of a query column. 156 * @param name value to set 157 **/ 158 public void setName(String name) { 159 column.setName(name); 160 } 161 162 /** set the value href 163 * URL to associate with the grid item. You can specify a URL that is relative to the current page 164 * @param href value to set 165 **/ 166 public void setHref(String href) { 167 column.setHref(href); 168 } 169 170 /** set the value type 171 * 172 * @param type value to set 173 **/ 174 public void setType(String type) { 175 column.setType(type); 176 } 177 178 /** set the value valuesdelimiter 179 * Character to use as a delimiter in the values and valuesDisplay attributes. Default 180 * is "," (comma). 181 * @param valuesdelimiter value to set 182 **/ 183 public void setValuesdelimiter(String valuesdelimiter) { 184 this.valuesdelimiter=valuesdelimiter; 185 } 186 187 /** set the value numberformat 188 * The format for displaying numeric data in the grid. For information about mask characters, 189 * see "numberFormat mask characters". 190 * @param numberformat value to set 191 **/ 192 public void setNumberformat(String numberformat) { 193 column.setNumberFormat(numberformat); 194 } 195 196 /** set the value header 197 * Text for the column header. The value of header is used only when the cfgrid colHeaders 198 * attribute is Yes (or omitted, since it defaults to Yes). 199 * @param header value to set 200 **/ 201 public void setHeader(String header) { 202 column.setHeader(header); 203 } 204 205 /** set the value textcolor 206 * Color value for grid element text in the grid column, or an expression you can use to manipulate text 207 * color in grid column elements. Valid color entries are: black (default), magenta, cyan, orange, 208 * arkgray, pink, gray, white, lightgray, yellow 209 * @param textcolor value to set 210 * @throws ExpressionException 211 **/ 212 public void setTextcolor(String textcolor) throws ExpressionException { 213 column.setTextColor(ColorCaster.toColor(textcolor)); 214 } 215 216 /** set the value select 217 * Yes or No. Yes lets end users select a column in a grid control. When No, the column cannot 218 * be edited, even if the cfgrid insert or delete attributes are enabled. The value of the select 219 * attribute is ignored if the cfgrid selectMode attribute is set to Row or Browse. 220 * @param select value to set 221 **/ 222 public void setSelect(boolean select) { 223 column.setSelect(select); 224 } 225 226 /** set the value headeralign 227 * Alignment for the column header text. Default is as specified by cfgrid. 228 * @param headeralign value to set 229 **/ 230 public void setHeaderalign(String headeralign) { 231 column.setHeaderAlign(headeralign); 232 } 233 234 /** set the value dataalign 235 * Alignment for column data. Entries are: left, center, or right. Default is as specified 236 * by cfgrid. 237 * @param dataalign value to set 238 **/ 239 public void setDataalign(String dataalign) { 240 column.setDataAlign(dataalign); 241 } 242 243 /** set the value bold 244 * Yes or No. Yes displays all grid control text in boldface. Default is as specified by the 245 * corresponding attribute of cfgrid. 246 * @param bold value to set 247 **/ 248 public void setBold(boolean bold) { 249 column.setBold(bold); 250 } 251 252 /** set the value headerbold 253 * Yes or No. Yes displays header text in boldface. Default is as specified by the 254 * corresponding attribute of cfgrid. 255 * @param headerbold value to set 256 **/ 257 public void setHeaderbold(boolean headerbold) { 258 column.setHeaderBold(headerbold); 259 } 260 261 /** set the value colheadertextcolor 262 * Color value for the grid control column header text. Entries are: black (default), magenta, 263 * cyan, orange, darkgray, pink, gray, white, lightgray, yellow. 264 * @param headertextcolor value to set 265 * @throws ExpressionException 266 **/ 267 public void setHeadertextcolor(String headertextcolor) throws ExpressionException { 268 column.setHeaderTextColor(ColorCaster.toColor(headertextcolor)); 269 } 270 271 /** set the value fontsize 272 * Font size for text in the column. Default is the font specified by cfgrid. 273 * @param fontsize value to set 274 **/ 275 public void setFontsize(double fontsize) { 276 column.setFontSize((int)fontsize); 277 } 278 279 280 @Override 281 public int doStartTag() throws PageException { 282 283 if(!StringUtil.isEmpty(values)) 284 column.setValues(ListUtil.toStringArray(ListUtil.listToArrayRemoveEmpty(values, valuesdelimiter))); 285 if(!StringUtil.isEmpty(valuesdisplay)) 286 column.setValuesDisplay(ListUtil.toStringArray(ListUtil.listToArrayRemoveEmpty(valuesdisplay, valuesdelimiter))); 287 288 // provide to parent 289 Tag parent=this; 290 do{ 291 parent = parent.getParent(); 292 if(parent instanceof Grid) { 293 ((Grid)parent).addColumn(column); 294 break; 295 } 296 } 297 while(parent!=null); 298 299 return SKIP_BODY; 300 } 301 302 @Override 303 public int doEndTag() { 304 return EVAL_PAGE; 305 } 306 307 308 }