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