KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > ivata > groupware > web > tag > webgui > tree > TreeSelectTag


1 /*
2  * Copyright (c) 2001 - 2005 ivata limited.
3  * All rights reserved.
4  * -----------------------------------------------------------------------------
5  * ivata groupware may be redistributed under the GNU General Public
6  * License as published by the Free Software Foundation;
7  * version 2 of the License.
8  *
9  * These programs are free software; you can redistribute them and/or
10  * modify them under the terms of the GNU General Public License
11  * as published by the Free Software Foundation; version 2 of the License.
12  *
13  * These programs are distributed in the hope that they will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16  *
17  * See the GNU General Public License in the file LICENSE.txt for more
18  * details.
19  *
20  * If you would like a copy of the GNU General Public License write to
21  *
22  * Free Software Foundation, Inc.
23  * 59 Temple Place - Suite 330
24  * Boston, MA 02111-1307, USA.
25  *
26  *
27  * To arrange commercial support and licensing, contact ivata at
28  * http://www.ivata.com/contact.jsp
29  * -----------------------------------------------------------------------------
30  * $Log: TreeSelectTag.java,v $
31  * Revision 1.5 2005/04/30 13:04:11 colinmacleod
32  * Fixes reverting id type from String to Integer.
33  *
34  * Revision 1.4 2005/04/29 02:48:14 colinmacleod
35  * Data bugfixes.
36  * Changed primary key back to Integer.
37  *
38  * Revision 1.3 2005/04/10 20:32:01 colinmacleod
39  * Added new themes.
40  * Changed id type to String.
41  * Changed i tag to em and b tag to strong.
42  * Improved PicoContainerFactory with NanoContainer scripts.
43  *
44  * Revision 1.2 2005/04/09 17:19:10 colinmacleod
45  * Changed copyright text to GPL v2 explicitly.
46  *
47  * Revision 1.1.1.1 2005/03/10 17:50:36 colinmacleod
48  * Restructured ivata op around Hibernate/PicoContainer.
49  * Renamed ivata groupware.
50  *
51  * Revision 1.2 2004/11/03 16:10:12 colinmacleod
52  * Changed todo comments to TODO: all caps.
53  *
54  * Revision 1.1 2004/09/30 15:16:03 colinmacleod
55  * Split off addressbook elements into security subproject.
56  *
57  * Revision 1.3 2004/07/13 19:41:15 colinmacleod
58  * Moved project to POJOs from EJBs.
59  * Applied PicoContainer to services layer (replacing session EJBs).
60  * Applied Hibernate to persistence layer (replacing entity EJBs).
61  *
62  * Revision 1.2 2004/03/21 21:16:18 colinmacleod
63  * Shortened name to ivata op.
64  *
65  * Revision 1.1.1.1 2004/01/27 20:57:58 colinmacleod
66  * Moved ivata openportal to SourceForge..
67  *
68  * Revision 1.2 2003/10/17 12:36:13 jano
69  * fixing problems with building
70  * converting intranet -> portal
71  * Eclipse building
72  *
73  * Revision 1.1.1.1 2003/10/13 20:50:13 colin
74  * Restructured portal into subprojects
75  *
76  * Revision 1.3 2003/08/05 14:51:48 jano
77  * fixing for addressBook extension
78  *
79  * Revision 1.2 2003/07/25 11:43:08 jano
80  * we have new field MaxDepth in treeSelect TAG
81  *
82  * Revision 1.1 2003/02/24 19:33:33 colin
83  * moved to jsp
84  *
85  * Revision 1.10 2003/02/19 07:58:31 colin
86  * fixed non-string properties
87  *
88  * Revision 1.9 2003/02/04 17:43:51 colin
89  * copyright notice
90  *
91  * Revision 1.8 2003/02/01 12:48:31 colin
92  * added style and styleClass attributes
93  *
94  * Revision 1.7 2003/01/28 12:57:36 colin
95  * moved HTML source to theme
96  * made TreeSelectClass a subclass of ControlTag
97  *
98  * Revision 1.6 2002/09/27 12:50:18 jano
99  * bug with useJavaScript
100  *
101  * Revision 1.5 2002/08/27 09:09:21 colin
102  * fixed selected (bug in setSelected)
103  *
104  * Revision 1.4 2002/06/28 13:24:20 colin
105  * allowed setSelected to also take a list as a parameter
106  *
107  * Revision 1.3 2002/06/21 12:11:13 colin
108  * restructured com.ivata.groupware.web and split into separate
109  * subcategories
110  *
111  * Revision 1.2 2002/06/13 15:45:15 peter
112  * brought over to peter, fixed bugs in webgui property-settings
113  *
114  * Revision 1.1 2002/06/13 07:44:07 colin
115  * first version of rose model: code tidied up/added javadoc
116  *
117  * Revision 1.5 2002/02/03 15:24:08 colin
118  * changed classname for User to PersonUser
119  *
120  * Revision 1.4 2002/02/02 21:23:01 colin
121  * major restructuring to make the Settings class more generic
122  * all default settings are now taken from the database rather
123  * than
124  * being hard coded in the settings class
125  * settings are stored in a HashMap in settings
126  *
127  * Revision 1.3 2002/01/27 19:55:48 colin
128  * updated the themes by removing the multiple section tags and
129  * replacing them with one tag and a Properties instance in
130  * com.ivata.groupware.web.theme.Theme
131  *
132  * Revision 1.2 2002/01/24 13:19:40 colin
133  * consolidated hanlding of theme and properties tags acoss
134  * webgui tag
135  * library
136  *
137  * Revision 1.1 2002/01/20 19:28:25 colin
138  * added tab and tree tags
139  * implemented address book functionality
140  * -----------------------------------------------------------------------------
141  */

142 package com.ivata.groupware.web.tag.webgui.tree;
143
144 import java.io.IOException JavaDoc;
145 import java.util.List JavaDoc;
146 import java.util.Properties JavaDoc;
147
148 import javax.servlet.jsp.JspException JavaDoc;
149 import javax.servlet.jsp.JspWriter JavaDoc;
150 import javax.swing.tree.TreeModel JavaDoc;
151
152 import com.ivata.groupware.web.tree.TreeNode;
153 import com.ivata.mask.util.CollectionHandling;
154 import com.ivata.mask.util.StringHandling;
155 import com.ivata.mask.web.tag.webgui.ControlTag;
156 import com.ivata.mask.web.theme.Theme;
157
158
159 /**
160  * <p>Create a tree from a {@link javax.swing.tree.TreeModel
161  * TreeModel}.</p>
162  * <p>This tree can be displayed as a:<br/>
163  * <ul>
164  * <li>combo box for single selection</li>
165  * <li>list control for multi-select displaying all tree nodes</li>
166  * </ul>
167  * </p>
168  * <p>In both cases, an HTML <code>&lt;select&gt;</code> is used in
169  * the
170  * implementation.</p>
171  * <p><strong>Tag attributes:</strong><br/>
172  * <table cellpadding='2' cellspacing='5' border='0' align='center'
173  * width='85%'>
174  * <tr class='TableHeadingColor'>
175  * <th>attribute</th>
176  * <th>reqd.</th>
177  * <th>param. class</th>
178  * <th width='100%'>description</th>
179  * </tr>
180  * <tr class='TableRowColor'>
181  * <td>controlName</td>
182  * <td>false</td>
183  * <td><code>String</code></td>
184  * <td>This attribute dictates the name of the list/combo box
185  * which is
186  * created.</td>
187  * </tr>
188  * <tr class='TableRowColor'>
189  * <td>defaultCaption</td>
190  * <td>false</td>
191  * <td><code>String</code></td>
192  * <td>If you specify treeStyle as 'combo', this sets the caption
193  * for the
194  * default option, such as "Please choose...".</td>
195  * </tr>
196  * <tr class='TableRowColor'>
197  * <td>defaultId</td>
198  * <td>false</td>
199  * <td><code>String</code></td>
200  * <td>If you specify treeStyle as 'combo', this sets the id value for the
201  * default selection.</td>
202  * </tr>
203  * <tr class='TableRowColor'>
204  * <td>listSize</td>
205  * <td>false</td>
206  * <td><code>Integer</code></td>
207  * <td>If you specify treeStyle as 'list', then this parameter
208  * controls
209  * the size of the list which is generated. The default is 15.</td>
210  * </tr>
211  * <tr class='TableRowColor'>
212  * <td>model</td>
213  * <td>true</td>
214  * <td>{@link javax.swing.tree.TreeModel
215  * javax.swing.tree.TreeModel}</td>
216  * <td>This model contains the data source for the tree. To use
217  * any
218  * datasource
219  * with this tree control, you should first create a class which
220  * implements
221  * {@link javax.swing.tree,TreeModel TreeModel}.</td>
222  * </tr>
223  * <tr class='TableRowColor'>
224  * <td>onChange</td>
225  * <td>false</td>
226  * <td><code>String</code></td>
227  * <td>This attribute dictates javascript to implement in the
228  * control's
229  * 'onChange' attribute.</td>
230  * </tr>
231  * <tr class='TableRowColor'>
232  * <td>readOnly</td>
233  * <td>false</td>
234  * <td><code>Boolean</code></td>
235  * <td>If set to <code>true</code>, then the control generated
236  * will be
237  * read only.</td>
238  * </tr>
239  * <tr class='TableRowColor'>
240  * <td>selected</td>
241  * <td>false</td>
242  * <td><code>String</code> or
243  * <code>java.util.List</code></td>
244  * <td>If you specify treeStyle as 'combo', then this attribute
245  * specifies
246  * the id of the tree node which is currently selected.<br/>
247  * If you specify treeStyle as 'list', then this attribute specifies
248  * all the ids of the tree nodes which are currently selected in the
249  * form
250  * of a list.</td>
251  * </tr>
252  * <tr class='TableRowColor'>
253  * <td>treeName</td>
254  * <td>true</td>
255  * <td><code>String</code></td>
256  * <td>Specifies a unique identifier for this tree, which is used
257  * to store
258  * the state of each foler (open/closed).</td>
259  * </tr>
260  * <tr class='TableRowColor'>
261  * <td>treeStyle</td>
262  * <td>false</td>
263  * <td><code>String</code></td>
264  * <td>Either 'combo' (default) or 'list', which results in a tree
265  * within
266  * an HTML <code>&lt;select&gt;</code> tag, as a pull-down control or
267  * list
268  * control respectively.<br/>
269  * </tr>
270  * <tr class='TableRowColor'>
271  * <td>useJavaScript</td>
272  * <td>false</td>
273  * <td><code>String</code></td>
274  * <td> If true, then the tree tab creates a control using
275  * javascript rather
276  * than implementing the control in HTML directly. This is only used
277  * if
278  * treeStyle is 'combo' or 'list'.</td>
279  * </tr>
280  * </table>
281  * </p>
282  *
283  * @since 2001-12-15
284  * @author Colin MacLeod
285  * <a HREF='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
286  * @version $Revision: 1.5 $
287  */

288 public class TreeSelectTag extends ControlTag {
289     /**
290      * <p>This is the special property used to identify the location
291      * of the children in the open tag.</p>
292      *
293      * <p><strong>Note</strong> that this has to be specified exactly, with <u>no
294      * spaces</u>.</p>
295      */

296     static final String JavaDoc childrenProperty = "treeChildren";
297     /**
298      * <p>Property declaration for tag attribute: controlName.</p>
299      */

300     private String JavaDoc controlName;
301     /**
302      * <p>Property declaration for tag attribute: defaultCaption</p>
303      */

304     private String JavaDoc defaultCaption = null;
305     /**
306      * <p>
307      * Identifer value of the default selection.
308      * </p>
309      */

310     private String JavaDoc defaultValue = "";
311     /**
312      * <p>Property declaration for tag attribute: listSize.</p>
313      */

314     private Integer JavaDoc listSize = new Integer JavaDoc (15);
315     /**
316      * <p>Property declaration for tag attribute: maxDepth.
317      * Starting at 1 - null. If null taking all children in root.</p>
318      */

319     private Integer JavaDoc maxDepth = null;
320     /**
321      * <p>Property declaration for tag attribute: model.</p>
322      */

323     private TreeModel JavaDoc model = null;
324     /**
325      * <p>Property declaration for tag attribute: onChange.</p>
326      */

327     private String JavaDoc onChange = null;
328     /**
329      * <p>TODO: add a comment here.</p>
330      */

331     private boolean readOnly;
332     /**
333      * <p>Property for tag attribute 'selected'.</p>
334      */

335     private String JavaDoc selected = null;
336     /**
337      * <p>Property for tag attribute 'selectedList'.</p>
338      */

339     private List JavaDoc selectedList = null;
340     /**
341      * <p>Property declaration for tag attribute: treeName.</p>
342      */

343     private String JavaDoc treeName = null;
344     /**
345      * <p>Property declaration for tag attribute: treeStyle.</p>
346      */

347     private String JavaDoc treeStyle = "combo";
348     /**
349      * <p>Property declaration for tag attribute: useJavaScript.</p>
350      */

351     private boolean useJavaScript = false;
352
353     /**
354      * <p>Default constructor.</p>
355      *
356      */

357     public TreeSelectTag() {
358         super();
359     }
360
361     /**
362      * <p>This is the method which performs the clever stuff and actually
363      * creates the tree by recursing on itself.</p>
364      *
365      * @param parent the parent of all the children we are going to create
366      * as
367      * options
368      * of the select.
369      * @param out the writer where all the results are written.
370      * @param actualDepth is a depth of actula parent.
371      * @throws JspException if there is any IOException writing to
372      * <code>out</code>.
373      *
374      */

375     private void createChildren(final Object JavaDoc parent,
376             final JspWriter JavaDoc out,
377             final int actualDepth) throws JspException JavaDoc {
378         String JavaDoc prependString = "";
379         for (int i=1; i<actualDepth; i++) {
380             if (useJavaScript) {
381                 prependString += "- ";
382             } else {
383                 prependString += "-&nbsp;";
384             }
385         }
386
387         try {
388             int totalNodes = model.getChildCount(parent);
389
390             for (int nodeNumber = 0; nodeNumber < totalNodes; ++nodeNumber) {
391                 TreeNode node = (TreeNode) model.getChild(parent, nodeNumber);
392                 String JavaDoc javaSript = "javascript:document.frmFolder" + node.getId() + ".submit( )";
393                 // the output depends on whether or not javajcript is used...
394
String JavaDoc sSpaces;
395
396                 if (useJavaScript) {
397                     out.println(controlName + ".options[ " + controlName + ".length ] = new Option( \"" + prependString + node.getName() + "\", " + node.getId() + " );");
398                     if (isSelected(node.getId())) {
399                         out.println(controlName + ".options[ " + controlName + ".length - 1 ].selected = true;");
400                     }
401                 } else {
402                     Theme theme = getTheme();
403                     Properties JavaDoc optionProperties = CollectionHandling.splice(getProperties(), new Properties JavaDoc());
404
405                     optionProperties.setProperty("value", StringHandling.getNotNull(node.getId(), "null"));
406                     if (isSelected(node.getId())) {
407                         optionProperties.setProperty("selected", "selected");
408                     }
409                     out.print(theme.parseSection("treeSelectOptionStart", optionProperties));
410                     out.print(prependString + node.getName());
411                     out.print(theme.parseSection("treeSelectOptionEnd", optionProperties));
412                 }
413                 // if this node has children and is open, then we have to create the children
414
// but only if actula Depth is not over Max Depth
415
if ( ((this.maxDepth==null) || (this.maxDepth!=null && actualDepth < this.maxDepth.intValue())) && (model.getChildCount(node) > 0)) {
416                     createChildren(node, out, actualDepth+1);
417                 }
418             }
419         } catch (IOException JavaDoc e) {
420             throw new JspException JavaDoc(e);
421         }
422     }
423
424     /**
425      * <p>This method is called when the JSP engine encounters the start
426      * tag,
427      * after the attributes are processed.<p>
428      *
429      * <p>Scripting variables (if any) have their values set here.</p>
430      *
431      * @return <code>SKIP_BODY</code> if this tag has no body or it
432      * should be skipped, otherwise <code>EVAL_BODY_BUFFERED</code>
433      * @throws JspException if there is an error retrieving the
434      * navigation
435      * object.
436      * @throws JspException if there is an error wrting to
437      * <code>out.print(
438      * )</code>
439      */

440     public int doStartTag() throws JspException JavaDoc {
441         super.doStartTag();
442         try {
443             // create the full tree ( null parent )
444
JspWriter JavaDoc out = pageContext.getOut();
445
446             // if we are outputting javascript, then just clear the control at this point
447
if (useJavaScript) {
448                 out.println(controlName + ".options.length=0;");
449             } else {
450                 // duplicate the standard properties and add to them
451
Properties JavaDoc properties = CollectionHandling.splice(getProperties(), new Properties JavaDoc());
452
453                 properties.setProperty("name", controlName);
454                 // the good old HTML will depend on whether this select is a combo or a list...
455
// if the tag is read only, put that attribute out
456
if (readOnly) {
457                     properties.setProperty("readOnly", "readOnly");
458                 }
459                 // if there is javascript for the onChange event, use that
460
if (onChange != null) {
461                     properties.setProperty("onChange", onChange);
462                 }
463
464                 String JavaDoc styleId = getStyleId();
465                 if (styleId != null) {
466                     properties.setProperty("styleId", styleId);
467                 }
468                 // likewise css style
469
String JavaDoc style = getStyle();
470                 if (style != null) {
471                     properties.setProperty("style", style);
472                 }
473                 String JavaDoc styleClass = getStyleClass();
474                 if (styleClass != null) {
475                     properties.setProperty("styleClass", styleClass);
476                 }
477                 TreeNode root = (TreeNode) model.getRoot();
478
479                 // if this is a list, then output the size of the list
480
if (treeStyle.equalsIgnoreCase("list")) {
481                     properties.setProperty("multiple", "multiple");
482                     properties.setProperty("listSize", listSize.toString());
483                 }
484                 Theme theme = getTheme();
485
486                 out.print(theme.parseSection("treeSelectStart", properties));
487                 if (defaultCaption != null) {
488                     Properties JavaDoc optionProperties = CollectionHandling.splice(getProperties(), new Properties JavaDoc());
489
490                     optionProperties.setProperty("value", defaultValue);
491                     out.print(theme.parseSection("treeSelectOptionStart", optionProperties));
492                     out.print(defaultCaption);
493                     out.print(theme.parseSection("treeSelectOptionEnd", optionProperties));
494                 }
495                 createChildren(root, out, 1);
496                 // if this is not javascript, then close the tag
497
if (!useJavaScript) {
498                     out.print(theme.parseSection("treeSelectEnd", properties));
499                 }
500             }
501         } catch (IOException JavaDoc ioException) {
502             throw new JspException JavaDoc(
503             "Error in TreeSelectTag: IOException whilst printing select.",
504                 ioException);
505         } catch (Exception JavaDoc e) {
506             throw new JspException JavaDoc("Error in TreeSelectTag: unhandled exception of class '"
507                     + e.getClass().getName() + "'",
508                     e);
509         }
510         // this tag has no body
511
return SKIP_BODY;
512     }
513
514     /**
515      * <p>Get the value supplied to the attribute 'controlName'.</p>
516      *
517      * <p>This attribute dictates the name of the list/combo box which is
518      * created.</p>
519      *
520      * @return the value supplied to the tag attribute 'controlName'.
521      *
522      */

523     public final String JavaDoc getControlName() {
524         return controlName;
525     }
526
527     /**
528      * <p>Get the value supplied to the attribute 'defaultCaption'.</p>
529      *
530      * <p>If you specify treeStyle as 'combo', this attribute sets the
531      * caption
532      * for the
533      * default option, such as "Please choose...".</p>
534      *
535      * @return the value supplied to the tag attribute 'defaultCaption'.
536      *
537      */

538     public final String JavaDoc getDefaultCaption() {
539         return defaultCaption;
540     }
541     /**
542      * <p>
543      * Identifer value of the default selection.
544      * </p>
545      *
546      * @return current value of defaultValue.
547      */

548     public final String JavaDoc getDefaultValue() {
549         return defaultValue;
550     }
551
552     /**
553      * <p>Get the value supplied to the attribute 'listSize'.</p>
554      *
555      * <p>If you specify treeStyle as 'list', then this parameter controls
556      * the size of the list which is generated. The default is 15.</p>
557      *
558      * @return the value supplied to the tag attribute 'listSize'.
559      *
560      */

561     public final Integer JavaDoc getListSize() {
562         return listSize;
563     }
564
565     /**
566      * <p>Property declaration for tag attribute: maxDepth.
567      * Starting at 1 - null. If null taking all children in root.</p>
568      *
569      *
570      * @return the current value of maxDepth.
571      */

572     public final Integer JavaDoc getMaxDepth() {
573         return this.maxDepth;
574     }
575
576     /**
577      * <p>Get the value supplied to the attribute 'model'.</p>
578      *
579      * <p>This model contains the data source for the tree. To use any
580      * datasource
581      * with this tree control, you should first create a class which
582      * implements
583      * {@link javax.swing.tree,TreeModel TreeModel}.</p>
584      *
585      * @return the value supplied to the tag attribute 'model'.
586      *
587      */

588     public final TreeModel JavaDoc getModel() {
589         return model;
590     }
591
592     /**
593      * <p>Get the value supplied to the attribute 'onChange'.</p>
594      *
595      * <p>This attribute dictates javascript to implement in the control's
596      * 'onChange'
597      * attribute.</p>
598      *
599      * @return the value supplied to the tag attribute 'onChange'.
600      *
601      */

602     public final String JavaDoc getOnChange() {
603         return onChange;
604     }
605
606     /**
607      * <p>Get the value supplied to the attribute 'readOnly'.</p>
608      *
609      * <p>If this attribute is set to <code>true</code>, then the control
610      * generated will be read only.</p>
611      *
612      * @return the value supplied to the tag attribute 'readOnly'.
613      *
614      */

615     public final boolean getReadOnly() {
616         return readOnly;
617     }
618
619     /**
620      * <p>Property for tag attribute 'selected'.</p>
621      *
622      * @return the current value of selected.
623      */

624     public final String JavaDoc getSelected() {
625         return selected;
626     }
627
628     /**
629      * <p>Property for tag attribute 'selectedList'.</p>
630      *
631      * @return the current value of selectedList.
632      */

633     public List JavaDoc getSelectedList() {
634         return selectedList;
635     }
636
637     /**
638      * <p>Get the value supplied to the attribute 'treeName'.</p>
639      *
640      * <p>This attribute specifies a unique identifier for this tree,
641      * which is
642      * used to store the state of each foler (open/closed).</p>
643      *
644      * @return the value supplied to the tag attribute 'treeName'.
645      *
646      */

647     public final String JavaDoc getTreeName() {
648         return treeName;
649     }
650
651     /**
652      * <p>Get the value supplied to the attribute 'treeStyle'.</p>
653      *
654      * <p>This attribute can be either 'combo' (default) or 'list', which
655      * results
656      * in a tree within an HTML <code>&lt;select&gt;</code> tag, as a
657      * pull-down
658      * control or list control respectively.</p>
659      *
660      * @return the value supplied to the tag attribute 'treeStyle'.
661      *
662      */

663     public final String JavaDoc getTreeStyle() {
664         return treeStyle;
665     }
666
667     /**
668      * <p>Get the value supplied to the attribute 'useJavaScript'.</p>
669      *
670      * <p>If true, then the tree tab creates a control using javascript
671      * rather
672      * than implementing the control in HTML directly. This is only used
673      * if
674      * treeStyle is 'combo' or 'list'.</p>
675      *
676      * @return the value supplied to the tag attribute 'useJavaScript'.
677      *
678      */

679     public final boolean getUseJavaScript() {
680         return useJavaScript;
681     }
682
683     /**
684      * <p>Helper function to see if an entry in the mulitple choice list
685      * is
686      * selected or not.</p>
687      *
688      * @param integerParam numeric identifier
689      * @return <code>true</code> if this id is in the list of selected
690      * ones,
691      * otherwise
692      * <code>false</code>
693      *
694      */

695     private boolean isSelected(Integer JavaDoc integerParam) {
696         if (selectedList != null) {
697             return (selectedList.indexOf(id) != -1);
698         } else {
699             return StringHandling.getNotNull(id).equals(selected);
700         }
701     }
702
703     /**
704      * <p>Set the value supplied to the attribute 'controlName'.</p>
705      *
706      * <p>This attribute dictates the name of the list/combo box which is
707      * created.</p>
708      *
709      * @param controlName the new value supplied to the tag attribute
710      * 'controlName'.
711      *
712      */

713     public final void setControlName(final String JavaDoc controlName) {
714         this.controlName = controlName;
715     }
716
717     /**
718      * <p>Set the value supplied to the attribute 'defaultCaption'.</p>
719      *
720      * <p>If you specify treeStyle as 'combo', this attribute sets the
721      * caption
722      * for the
723      * default option, such as "Please choose...".</p>
724      *
725      * @param defaultCaption the value supplied to the tag attribute
726      * 'defaultCaption'.
727      *
728      */

729     public final void setDefaultCaption(final String JavaDoc defaultCaption) {
730         this.defaultCaption = defaultCaption;
731     }
732     /**
733      * <p>
734      * Identifer value of the default selection.
735      * </p>
736      *
737      * @param defaultValue new value of defaultValue.
738      */

739     public final void setDefaultValue(final String JavaDoc defaultValue) {
740         this.defaultValue = defaultValue;
741     }
742
743     /**
744      * <p>Set the value supplied to the attribute 'listSize'.</p>
745      *
746      * <p>If you specify treeStyle as 'list', then this parameter controls
747      * the size of the list which is generated. The default is 15.</p>
748      *
749      * @param listSize the new value supplied to the tag attribute
750      * 'listSize'.
751      *
752      */

753     public final void setListSize(final Integer JavaDoc listSize) {
754         this.listSize = listSize;
755     }
756
757     /**
758      * <p>Property declaration for tag attribute: maxDepth.
759      * Starting at 1 - null. If null taking all children in root.</p>
760      *
761      *
762      * @param maxDepth the new value of maxDepth.
763      */

764     public final void setMaxDepth(final Integer JavaDoc maxDepth) {
765         this.maxDepth = maxDepth;
766     }
767
768     /**
769      * <p>Set the value supplied to the attribute 'model'.</p>
770      *
771      * <p>This model contains the data source for the tree. To use any
772      * datasource
773      * with this tree control, you should first create a class which
774      * implements
775      * {@link javax.swing.tree,TreeModel TreeModel}.</p>
776      *
777      * @param model the new value supplied to the tag attribute 'model'.
778      *
779      */

780     public final void setModel(final TreeModel JavaDoc model) {
781         this.model = model;
782     }
783
784     /**
785      * <p>Set the value supplied to the attribute 'onChange'.</p>
786      *
787      * <p>This attribute dictates javascript to implement in the control's
788      * 'onChange'
789      * attribute.</p>
790      *
791      * @param onChange the new value supplied to the tag attribute
792      * 'onChange'.
793      *
794      */

795     public final void setOnChange(final String JavaDoc onChange) {
796         this.onChange = onChange;
797     }
798
799     /**
800      * <p>Set the value supplied to the attribute 'readOnly'.</p>
801      *
802      * <p>If this attribute is set to <code>true</code>, then the control
803      * generated will be read only.</p>
804      *
805      * @param readOnly the new value supplied to the tag attribute
806      * 'readOnly'.
807      *
808      */

809     public final void setReadOnly(final boolean readOnly) {
810         this.readOnly = readOnly;
811     }
812
813     /**
814      * <p>Property for tag attribute 'selected'.</p>
815      *
816      * @param selected the new value of selected.
817      */

818     public final void setSelected(final String JavaDoc selected) {
819         this.selected = selected;
820     }
821
822     /**
823      * <p>Property for tag attribute 'selectedList'.</p>
824      *
825      * @param selectedList the new value of selectedList.
826      */

827     public final void setSelectedList(final List JavaDoc selectedList) {
828         this.selectedList = selectedList;
829     }
830
831     /**
832      * <p>Set the value supplied to the attribute 'treeName'.</p>
833      *
834      * <p>This attribute specifies a unique identifier for this tree,
835      * which is
836      * used to store the state of each foler (open/closed).</p>
837      *
838      * @param treeName the new value supplied to the tag attribute
839      * 'treeName'.
840      *
841      */

842     public final void setTreeName(final String JavaDoc treeName) {
843         this.treeName = treeName;
844     }
845
846     /**
847      * <p>Set the value supplied to the attribute 'treeStyle'.</p>
848      *
849      * <p>This attribute can be either 'combo' (default) or 'list', which
850      * results
851      * in a tree within an HTML <code>&lt;select&gt;</code> tag, as a
852      * pull-down
853      * control or list control respectively.</p>
854      *
855      * @param treeStyle the new value supplied to the tag attribute
856      * 'treeStyle'.
857      *
858      */

859     public final void setTreeStyle(final String JavaDoc treeStyle) {
860         this.treeStyle = treeStyle;
861     }
862
863     /**
864      * <p>Set the value supplied to the attribute 'useJavaScript'.</p>
865      *
866      * <p>If true, then the tree tab creates a control using javascript
867      * rather
868      * than implementing the control in HTML directly. This is only used
869      * if
870      * treeStyle is 'combo' or 'list'.</p>
871      *
872      * @param useJavaScript the new value supplied to the tag attribute
873      * 'useJavaScript'.
874      *
875      */

876     public final void setUseJavaScript(final boolean useJavaScript) {
877         this.useJavaScript = useJavaScript;
878     }
879 }
880
Popular Tags