KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > jcorporate > expresso > ext > taglib > InputTag


1 /* ====================================================================
2  * The Jcorporate Apache Style Software License, Version 1.2 05-07-2002
3  *
4  * Copyright (c) 1995-2002 Jcorporate Ltd. All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions
8  * are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright
11  * notice, this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright
14  * notice, this list of conditions and the following disclaimer in
15  * the documentation and/or other materials provided with the
16  * distribution.
17  *
18  * 3. The end-user documentation included with the redistribution,
19  * if any, must include the following acknowledgment:
20  * "This product includes software developed by Jcorporate Ltd.
21  * (http://www.jcorporate.com/)."
22  * Alternately, this acknowledgment may appear in the software itself,
23  * if and wherever such third-party acknowledgments normally appear.
24  *
25  * 4. "Jcorporate" and product names such as "Expresso" must
26  * not be used to endorse or promote products derived from this
27  * software without prior written permission. For written permission,
28  * please contact info@jcorporate.com.
29  *
30  * 5. Products derived from this software may not be called "Expresso",
31  * or other Jcorporate product names; nor may "Expresso" or other
32  * Jcorporate product names appear in their name, without prior
33  * written permission of Jcorporate Ltd.
34  *
35  * 6. No product derived from this software may compete in the same
36  * market space, i.e. framework, without prior written permission
37  * of Jcorporate Ltd. For written permission, please contact
38  * partners@jcorporate.com.
39  *
40  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
41  * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
42  * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
43  * DISCLAIMED. IN NO EVENT SHALL JCORPORATE LTD OR ITS CONTRIBUTORS
44  * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
45  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
46  * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
47  * USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
48  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
49  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
50  * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
51  * SUCH DAMAGE.
52  * ====================================================================
53  *
54  * This software consists of voluntary contributions made by many
55  * individuals on behalf of the Jcorporate Ltd. Contributions back
56  * to the project(s) are encouraged when you make modifications.
57  * Please send them to support@jcorporate.com. For more information
58  * on Jcorporate Ltd. and its products, please see
59  * <http://www.jcorporate.com/>.
60  *
61  * Portions of this software are based upon other open source
62  * products and are subject to their respective licenses.
63  */

64
65 package com.jcorporate.expresso.ext.taglib;
66
67 import com.jcorporate.expresso.core.controller.Input;
68 import com.jcorporate.expresso.core.dbobj.ValidValue;
69 import com.jcorporate.expresso.core.misc.StringUtil;
70 import com.jcorporate.expresso.kernel.util.FastStringBuffer;
71 import org.apache.log4j.Logger;
72
73 import javax.servlet.jsp.JspTagException JavaDoc;
74 import javax.servlet.jsp.JspWriter JavaDoc;
75 import javax.servlet.jsp.tagext.Tag JavaDoc;
76 import java.util.Vector JavaDoc;
77
78
79 /**
80  * The InputTag renders an Expresso Input item in HTML, either
81  * as an inputbox, or as a select box.
82  *
83  * @author Adam Rossi
84  */

85 public class InputTag extends ExpressoTagSupport {
86
87     public static final String JavaDoc TYPE_CHECKBOX = "checkbox";
88     public static final String JavaDoc TYPE_CHECKBOX_VERT = "checkbox-vertical";
89     // input type=hidden
90
public static final String JavaDoc TYPE_HIDDEN = "hidden";
91     public static final String JavaDoc TYPE_READONLY = "readonly";
92     // input type=radio
93
public static final String JavaDoc TYPE_RADIO = "radio";
94     public static final String JavaDoc TYPE_RADIO_VERT = "radio-vertical";
95     // select list
96
public static final String JavaDoc TYPE_DROPDOWN = "dropdown";
97     public static final String JavaDoc TYPE_LISTBOX = "listbox";
98     // textarea
99
public static final String JavaDoc TYPE_TEXTAREA = "textarea";
100
101     // Input types not explicitly handled by InputTag but often used and could
102
// be explicitly handle in the future
103
public static final String JavaDoc TYPE_FILE = "file";
104     public static final String JavaDoc TYPE_PASSWORD = "password";
105     public static final String JavaDoc TYPE_TEXT = "text";
106
107     // Style Sheet classes
108
// Where are these constant actually used in this class? *PP*
109
public static final String JavaDoc STYLE_SHEET_MEDIUM_BOLD = "mediumbold";
110     public static final String JavaDoc STYLE_SHEET_MEDIUM_TEXT = "mediumtext";
111
112
113     private java.lang.String JavaDoc name = null; //by default, name is controller
114
private java.lang.String JavaDoc value = null; //by default, empty string
115
private java.lang.String JavaDoc type = null;
116     private java.lang.String JavaDoc size = null;
117     private java.lang.String JavaDoc maxlength = null;
118     private java.lang.String JavaDoc multiple = null;
119     private java.lang.String JavaDoc showlabel = null; //by default, do not show a label
120
private java.lang.String JavaDoc label = null;
121     private java.lang.String JavaDoc nameToUse = null; //by default, name is controller
122
private java.lang.String JavaDoc valueToUse = null; //by default, empty string
123
private java.lang.String JavaDoc typeToUse = null;
124     private java.lang.String JavaDoc sizeToUse = null;
125     private java.lang.String JavaDoc maxlengthToUse = null;
126     private java.lang.String JavaDoc multipleToUse = null;
127     private java.lang.String JavaDoc labelToUse = null;
128     private Input oneInput = null;
129     private static Logger log = Logger.getLogger(InputTag.class);
130
131
132     /**
133      * HTML Element style attribute
134      */

135     private String JavaDoc style=null;
136     
137     /**
138      * HTML Element class attribute
139      */

140     private String JavaDoc styleClass=null;
141     /**
142      * HTML Element style Id attribute
143      */

144     private String JavaDoc styleId=null;
145     
146     /**
147      * Javascript 1.2 property <em>HTMLElement.onclick</em>
148      */

149     private String JavaDoc onclick=null;
150     
151     /**
152      * Javascript 1.2 property <em>HTMLElement.ondblclick</em>
153      */

154     private String JavaDoc ondblclick=null;
155     
156     /**
157      * Javascript 1.2 property <em>HTMLElement.onhelp</em>
158      */

159     private String JavaDoc onhelp=null;
160     
161     /**
162      * Javascript 1.2 property <em>HTMLElement.onkeydown</em>
163      */

164     private String JavaDoc onkeydown=null;
165     
166     /**
167      * Javascript 1.2 property <em>HTMLElement.onkeypress</em>
168      */

169     private String JavaDoc onkeypress=null;
170     
171     /**
172      * Javascript 1.2 property <em>HTMLElement.onkeyup</em>
173      */

174     private String JavaDoc onkeyup=null;
175     
176     /**
177      * Javascript 1.2 property <em>HTMLElement.onmousedown</em>
178      */

179     private String JavaDoc onmousedown=null;
180     
181     /**
182      * Javascript 1.2 property <em>HTMLElement.onmousemove</em>
183      */

184     private String JavaDoc onmousemove=null;
185     
186     /**
187      * Javascript 1.2 property <em>HTMLElement.onmouseout</em>
188      */

189     private String JavaDoc onmouseout=null;
190     
191     /**
192      * Javascript 1.2 property <em>HTMLElement.onmouseover</em>
193      */

194     private String JavaDoc onmouseover=null;
195     
196     /**
197      * Javascript 1.2 property <em>HTMLElement.onmouseup</em>
198      */

199     private String JavaDoc onmouseup=null;
200     
201     /**
202      * Number of rows for a HTML text area
203      */

204     private int rows=4;
205     
206     /**
207      * Number of columns for a HTML text area
208      */

209     private int cols=40;
210     
211     /**
212      * Default rows setting
213      */

214     public final static int DEFAULT_ROWS=4;
215
216     /**
217      * Default columns setting
218      */

219     public final static int DEFAULT_COLUMNS=4;
220     
221     
222     /**
223      *
224      */

225     public InputTag() {
226         super();
227     } /* InputTag() */
228
229     /**
230      * We examine the Input object and populate the instance variables
231      *
232      * @throws java.lang.Exception if input member is null
233      */

234     private void analyzeInput()
235             throws Exception JavaDoc {
236         if (oneInput == null) {
237             throw new Exception JavaDoc("The Input object was null");
238         }
239         //any attribute arguments from the page take precedence over Expresso Input
240
//attributes
241
if (nameToUse == null) {
242             nameToUse = StringUtil.notNull(oneInput.getName());
243         }
244         if (valueToUse == null) {
245             valueToUse = StringUtil.notNull(oneInput.getDefaultValue());
246         }
247         if (typeToUse == null) {
248             typeToUse = StringUtil.notNull(oneInput.getType());
249         }
250         if (sizeToUse == null) {
251             sizeToUse = StringUtil.notNull("" + oneInput.getDisplayLength());
252         }
253         if (maxlengthToUse == null) {
254             maxlengthToUse = StringUtil.notNull("" + oneInput.getMaxLength());
255         }
256         if (labelToUse == null) {
257             labelToUse = StringUtil.notNull(oneInput.getLabel());
258         }
259     } /* analyzeInput() */
260
261
262     /**
263      * Generates HTML attributes for style, class, and style id
264      * @param buf
265      * @return
266      */

267     protected FastStringBuffer generateStyleClass( FastStringBuffer buf )
268     {
269         if ( style != null )
270             buf.append( "style=\""+style+"\" ");
271         if ( styleClass != null )
272             buf.append( "class=\""+styleClass+"\" ");
273         if ( styleId != null )
274             buf.append( "style=\""+styleId+"\" ");
275         return buf;
276     }
277     
278     /**
279      * Generates HTML attributes for the JavaScript event handler
280      * @param buf
281      * @return
282      */

283     protected FastStringBuffer generateEventHandler( FastStringBuffer buf )
284     {
285         if ( onclick != null )
286             buf.append( "=\""+onclick+"\" ");
287         if ( ondblclick != null )
288             buf.append( "=\""+ondblclick+"\" ");
289         if ( onhelp != null )
290             buf.append( "onhelp=\""+onhelp+"\" ");
291         if ( onkeydown != null )
292             buf.append( "onkeydown=\""+onkeydown+"\" ");
293         if ( onkeypress != null )
294             buf.append( "onkeypress=\""+onkeypress+"\" ");
295         if ( onkeydown != null )
296             buf.append( "onkeydown=\""+onkeydown+"\" ");
297         if ( onmousedown!= null )
298             buf.append( "onmousedown=\""+onmousedown+"\" ");
299         if ( onmousemove!= null )
300             buf.append( "onmousemove=\""+onmousemove+"\" ");
301         if ( onmouseout!= null )
302             buf.append( "onmouseout=\""+onmouseout+"\" ");
303         if ( onmouseover!= null )
304             buf.append( "onmouseover=\""+onmouseover+"\" ");
305         if ( onmouseup!= null )
306             buf.append( "onmouseup=\""+onmouseup+"\" ");
307         return buf;
308     }
309
310     /**
311      * Build an input text box
312      *
313      * @param writer the JspWriter
314      * @throws Exception upon error
315      */

316     private void buildBox(JspWriter JavaDoc writer)
317             throws Exception JavaDoc {
318         if (writer == null) {
319             throw new Exception JavaDoc("JspWriter was null");
320         }
321
322         FastStringBuffer fsb = FastStringBuffer.getInstance();
323         try {
324             fsb.append("<input type=\"");
325             fsb.append(typeToUse);
326             fsb.append("\" name=\"");
327             fsb.append(nameToUse);
328             fsb.append("\" size=\"");
329             fsb.append(sizeToUse);
330             fsb.append("\" maxlength=\"");
331             fsb.append(maxlengthToUse);
332             fsb.append("\" value=\"");
333             fsb.append(valueToUse);
334             fsb.append("\" ");
335             generateStyleClass( fsb );
336             generateEventHandler( fsb );
337             fsb.append(">");
338 // writer.print("<input type=\"" + typeToUse + "\" name=\"" + nameToUse +
339
// "\" size=\"" + sizeToUse + "\" maxlength=\"" +
340
// maxlengthToUse + "\" value=\"" + valueToUse + "\">");
341
writer.print(fsb.toString());
342         } finally {
343             fsb.release();
344         }
345     } /* buildBox(JSPWriter) */
346
347     /**
348      * Build an input text box that is readonly
349      *
350      * @param writer the JspWriter
351      * @throws Exception upon error
352      */

353     private void buildReadOnlyBox(JspWriter JavaDoc writer)
354             throws Exception JavaDoc {
355         if (writer == null) {
356             throw new Exception JavaDoc("JspWriter was null");
357         }
358
359         FastStringBuffer fsb = FastStringBuffer.getInstance();
360         try {
361             fsb.append("<input type=\"");
362             fsb.append(typeToUse);
363             fsb.append("\" name=\"");
364             fsb.append(nameToUse);
365             fsb.append("\" readonly\"");
366             fsb.append("\" size=\"");
367             fsb.append(sizeToUse);
368             fsb.append("\" maxlength=\"");
369             fsb.append(maxlengthToUse);
370             fsb.append("\" value=\"");
371             fsb.append(valueToUse);
372             fsb.append("\" ");
373             generateStyleClass( fsb );
374             generateEventHandler( fsb );
375             fsb.append(" >");
376 // writer.print("<input type=\"" + typeToUse + "\" name=\"" + nameToUse +
377
// "\" size=\"" + sizeToUse + "\" maxlength=\"" +
378
// maxlengthToUse + "\" value=\"" + valueToUse + "\">");
379
writer.print(fsb.toString());
380         } finally {
381             fsb.release();
382         }
383     } /* buildBox(JSPWriter) */
384
385
386     /**
387      * Builds a checkbox from the input object.
388      *
389      * @param writer The JspWriter
390      * @param vertical true if you want vertically aligned check boxes
391      */

392     private void buildCheckBox(JspWriter JavaDoc writer, boolean vertical)
393             throws Exception JavaDoc {
394         if (writer == null) {
395             throw new Exception JavaDoc("JspWriter was null");
396         }
397
398         Vector JavaDoc validVector = oneInput.getValidValues();
399         ValidValue oneValue = null;
400         String JavaDoc checkFlag = null;
401
402         for (int i = 0; i < validVector.size(); i++) {
403             oneValue = (ValidValue) validVector.elementAt(i);
404
405             if (valueToUse.equals(oneValue.getValue())) {
406                 checkFlag = "CHECKED";
407             } else {
408                 checkFlag = "";
409             }
410             FastStringBuffer fsb = FastStringBuffer.getInstance();
411             try {
412                 fsb.append(" <input type=\"checkbox\" name=\"");
413                 fsb.append(nameToUse);
414                 fsb.append("\" ");
415                 fsb.append(checkFlag);
416                 fsb.append(" value=\"");
417                 fsb.append(oneValue.getValue());
418                 fsb.append("\" ");
419                 generateStyleClass( fsb );
420                 generateEventHandler( fsb );
421                 fsb.append(">");
422                 fsb.append(oneValue.getDescription());
423
424 // writer.println(" <input type=\"checkbox\" " + "name=\"" +
425
// nameToUse + "\" " + checkFlag + " value=\"" +
426
// oneValue.getValue() + "\"> " +
427
// oneValue.getDescription());
428

429                 if (vertical) {
430                     fsb.append(" <br />");
431                 }
432                 writer.print(fsb.toString());
433             } finally {
434                 fsb.release();
435             }
436         }
437     } /* buildCheckBox(JSPWriter) */
438
439
440     /**
441      * Build a hidden text field
442      *
443      * @param writer the Jsp Writer
444      * @throws Exception upon error
445      */

446     private void buildHiddenBox(JspWriter JavaDoc writer)
447             throws Exception JavaDoc {
448         if (writer == null) {
449             throw new Exception JavaDoc("JspWriter was null");
450         }
451
452         FastStringBuffer fsb = FastStringBuffer.getInstance();
453         try {
454             fsb.append(" <input type=\"hidden\" name=\"");
455             fsb.append(nameToUse);
456             fsb.append("\" size=\"");
457             fsb.append(sizeToUse);
458             fsb.append("\" maxlength=\"");
459             fsb.append(maxlengthToUse);
460             fsb.append("\" value=\"");
461             fsb.append(valueToUse);
462             fsb.append("\" ");
463             generateStyleClass( fsb );
464             generateEventHandler( fsb );
465             fsb.append(">");
466
467 // writer.print("<input type=\"hidden\" name=\"" + nameToUse +
468
// "\" size=\"" + sizeToUse + "\" maxlength=\"" +
469
// maxlengthToUse + "\" value=\"" + valueToUse + "\">");
470
writer.print(fsb.toString());
471         } finally {
472             fsb.release();
473         }
474     } /* buildBox(JSPWriter) */
475
476
477     /**
478      * Builds a radio input field from the input object.
479      *
480      * @param writer the Jsp Writer
481      * @param vertical if you want vertical radio buttons
482      * @throws Exception upon error
483      */

484     private void buildRadioButton(JspWriter JavaDoc writer, boolean vertical)
485             throws Exception JavaDoc {
486         if (writer == null) {
487             throw new Exception JavaDoc("JspWriter was null");
488         }
489
490         Vector JavaDoc validVector = oneInput.getValidValues();
491         ValidValue oneValue = null;
492         String JavaDoc checkFlag = null;
493
494         for (int i = 0; i < validVector.size(); i++) {
495             oneValue = (ValidValue) validVector.elementAt(i);
496
497             if (valueToUse.equals(oneValue.getValue())) {
498                 checkFlag = "CHECKED";
499             } else {
500                 checkFlag = "";
501             }
502
503             FastStringBuffer fsb = FastStringBuffer.getInstance();
504             try {
505                 fsb.append("<input type=\"radio\" name=\"");
506                 fsb.append(nameToUse);
507                 fsb.append("\" ");
508                 fsb.append(checkFlag);
509                 fsb.append(" value=\"");
510                 fsb.append(oneValue.getValue());
511                 fsb.append("\" ");
512                 generateStyleClass( fsb );
513                 generateEventHandler( fsb );
514                 fsb.append(">");
515                 fsb.append(oneValue.getDescription());
516
517 // writer.println(" <input type=\"radio\" " + "name=\"" + nameToUse +
518
// "\" " + checkFlag + " value=\"" +
519
// oneValue.getValue() + "\"> " +
520
// oneValue.getDescription());
521
//
522
if (vertical) {
523                     fsb.append(" <br />");
524                 }
525
526                 writer.print(fsb.toString());
527             } finally {
528                 fsb.release();
529             }
530         }
531     } /* buildRadioButton(JSPWriter) */
532
533
534     /**
535      * Builds a typical drop down list from the input object.
536      *
537      * @param writer the JspWriter object
538      * @throws Exception upon error
539      */

540     private void buildSelectList(JspWriter JavaDoc writer)
541             throws Exception JavaDoc {
542         if (writer == null) {
543             throw new Exception JavaDoc("JspWriter was null");
544         }
545
546         FastStringBuffer fsb = FastStringBuffer.getInstance();
547
548         try {
549             Vector JavaDoc validVector = oneInput.getValidValues();
550             ValidValue oneValue = null;
551             fsb.append("<select name=\"");
552             fsb.append(nameToUse);
553             fsb.append("\"");
554             if (size != null) {
555                 fsb.append(" size=\"");
556                 fsb.append(size);
557                 fsb.append("\"");
558 // str=str+" size=\"" + size + "\"";
559
if (multiple != null && multiple.equals("true")) {
560                     fsb.append(" multiple=\"true\"");
561                 }
562             }
563             fsb.append("\" ");
564             generateStyleClass( fsb );
565             generateEventHandler( fsb );
566             fsb.append(">");
567
568 // writer.println("<select name=\"" + nameToUse + "\">");
569

570             //If there is no current selection, we put an empty selection and make
571
//it selected
572
boolean noEmptyValue = true;
573
574             for (int i = 0; i < validVector.size(); i++) {
575                 oneValue = (ValidValue) validVector.elementAt(i);
576
577                 if ("".equals(oneValue.getValue())) {
578                     noEmptyValue = false;
579                 }
580             }
581             if (noEmptyValue) {
582                 if ("".equals(valueToUse)) {
583                     fsb.append(" <option value=\"\" SELECTED>(select...)</option>");
584 // writer.println(" <option value=\"\" SELECTED>(select...)</option>");
585
}
586 // else {
587
// fsb.append(" <option value=\"\" >(select...)</option>");
588
// writer.println(" <option value=\"\" >(select...)</option>");
589
// }
590
}
591
592             String JavaDoc selectFlag = null;
593
594             for (int i = 0; i < validVector.size(); i++) {
595                 oneValue = (ValidValue) validVector.elementAt(i);
596
597                 if (valueToUse.equals(oneValue.getValue())) {
598                     selectFlag = "SELECTED";
599                 } else {
600                     selectFlag = "";
601                 }
602                 fsb.append(" <option value=\"");
603                 fsb.append(oneValue.getValue());
604                 fsb.append("\" ");
605                 fsb.append(selectFlag);
606                 fsb.append(">");
607                 fsb.append(oneValue.getDescription());
608                 fsb.append("</option>");
609
610 // writer.println(" <option value=\"" + oneValue.getValue() + "\" " +
611
// selectFlag + ">" + oneValue.getDescription() +
612
// "</option>");
613
}
614             fsb.append(" </select>\n");
615
616 // writer.println("</select>");
617
writer.print(fsb.toString());
618         } finally {
619             fsb.release();
620         }
621     } /* buildSelectList(JSPWriter) */
622
623
624     /**
625      * Build a Text Area Input box
626      *
627      * @param writer the Jsp Writer Object
628      * @throws Exception upon error
629      */

630     private void buildTextArea(JspWriter JavaDoc writer)
631             throws Exception JavaDoc {
632         if (writer == null) {
633             throw new Exception JavaDoc("JspWriter was null");
634         }
635
636         FastStringBuffer fsb = FastStringBuffer.getInstance();
637         try {
638             fsb.append("<textarea name=\"");
639             fsb.append(nameToUse);
640             fsb.append("\" ");
641             if ( rows > 0 )
642                 fsb.append( "rows=\""+rows+"\" ");
643             if ( cols > 0 )
644                 fsb.append( "cols=\""+cols+"\" ");
645             generateStyleClass( fsb );
646             generateEventHandler( fsb );
647             fsb.append(" >");
648             fsb.append(valueToUse);
649             fsb.append("</textarea>");
650             writer.print(fsb.toString());
651         } finally {
652             fsb.release();
653         }
654
655
656 // writer.print("<textarea name=\"" + nameToUse +
657
// "\" rows=\"4\" cols=\"40\">" + valueToUse +
658
// "</textarea>");
659
} /* buildBox(JSPWriter) */
660
661
662     /**
663      * Standard doEndTag.
664      *
665      * @return int
666      */

667     public int doEndTag()
668             throws javax.servlet.jsp.JspTagException JavaDoc {
669         nameToUse = name;
670         valueToUse = value;
671         typeToUse = type;
672         sizeToUse = size;
673         maxlengthToUse = maxlength;
674         labelToUse = label;
675         getControllerResponse();
676
677         try {
678
679             // An InputTag can be contained either directly in the ControllerResponse,
680
// or, by a parent ElementIterator or Block tag.
681
Tag JavaDoc container = getContainer();
682
683             if (container == null) {
684                 oneInput = ctlrResp.getInput(nameToUse);
685             } else {
686                 if (container instanceof ElementIterator) {
687                     oneInput = (Input) ((ElementIterator) container).getElement();
688                     nameToUse = oneInput.getName();
689                 } else if (container instanceof BlockTag) {
690                     oneInput = (Input) ((BlockTag) container).getBlock().getContent(getName());
691                 } else {
692                     throw new JspTagException JavaDoc("InputTag: cannot handle container tag" +
693                             container.getClass().getName());
694                 }
695             }
696
697             JspWriter JavaDoc writer = pageContext.getOut();
698
699             if (oneInput != null) {
700                 this.analyzeInput();
701
702                 if ("true".equalsIgnoreCase(showlabel)) {
703
704                     //first write out the label for this input
705
//by default, this is false
706
/** @todo print </td> when outputting labels *RD* Mon Jul 27 2004 */
707                     if (!"".equals(labelToUse)) {
708                         writer.print(labelToUse + "</td> ");
709                     }
710
711                 }
712
713                 /** @todo check if the field is a multi valued select so it can be correctly built *RD* Mon Jul 27 2004 */
714                 if (Input.ATTRIBUTE_LISTBOX.equalsIgnoreCase(typeToUse)) {
715                     this.setSize(Integer.toString(oneInput.getLines()));
716                     this.setMultiple(oneInput.getMultiple());
717                     this.buildSelectList(writer);
718                     this.setSize("");
719                     this.setMultiple("");
720                 } else if (Input.ATTRIBUTE_DROPDOWN.equalsIgnoreCase(typeToUse)) {
721                     this.buildSelectList(writer);
722                 } else if (Input.ATTRIBUTE_CHECKBOX.equalsIgnoreCase(typeToUse)) {
723                     this.buildCheckBox(writer, false);
724                 } else if (Input.ATTRIBUTE_CHECKBOX_VERTICAL.equalsIgnoreCase(typeToUse)) {
725                     this.buildCheckBox(writer, true);
726                 } else if (Input.ATTRIBUTE_RADIO.equalsIgnoreCase(typeToUse)) {
727                     this.buildRadioButton(writer, false);
728                 } else if (Input.ATTRIBUTE_RADIO_VERTICAL.equalsIgnoreCase(typeToUse)) {
729                     this.buildRadioButton(writer, true);
730                 } else if (Input.ATTRIBUTE_TEXTAREA.equalsIgnoreCase(typeToUse)) {
731                     this.buildTextArea(writer);
732                 } else if (Input.ATTRIBUTE_HIDDEN.equalsIgnoreCase(typeToUse)) {
733                     this.buildHiddenBox(writer);
734                 } else if (Input.ATTRIBUTE_READONLY.equalsIgnoreCase(typeToUse)) {
735                     this.buildReadOnlyBox(writer);
736                 } else {
737
738                     // case for ATTRIBUTE_TEXTLINE handled here too
739
//assume normal box
740
this.buildBox(writer);
741                 }
742             } else {
743                 writer.println("The Input Named " + nameToUse +
744                         " Could Not Be Displayed");
745             }
746         } catch (Exception JavaDoc e) {
747             log.error(e);
748             throw new JspTagException JavaDoc("InputTag: " + e.getMessage());
749         }
750
751         return EVAL_PAGE;
752     } /* doEndTag() */
753
754
755     /**
756      * Do nothing until end tag.
757      *
758      * @return int
759      * @throws javax.servlet.jsp.JspTagException
760      * The exception description.
761      */

762     public int doStartTag()
763             throws javax.servlet.jsp.JspTagException JavaDoc {
764         return SKIP_BODY;
765     } /* doStartTag() */
766
767
768     /**
769      * Getter method for maxlength.
770      *
771      * @return java.lang.String
772      */

773     public java.lang.String JavaDoc getMaxlength() {
774         return maxlengthToUse;
775     } /* getMaxLength() */
776
777
778     /**
779      * Gets the multiple value to use
780      *
781      * @return java.lang.String
782      */

783     public java.lang.String JavaDoc getMultiple() {
784         return multipleToUse;
785     }
786
787     /**
788      * Getter method for Name.
789      *
790      * @return java.lang.String
791      */

792     public java.lang.String JavaDoc getName() {
793         return nameToUse;
794     } /* getName() */
795
796     /**
797      * Getter Method for showlabel.
798      *
799      * @return java.lang.String
800      */

801     public java.lang.String JavaDoc getShowlabel() {
802         return showlabel;
803     } /* getShowlabel() */
804
805     /**
806      * Getter method for size.
807      *
808      * @return java.lang.String
809      */

810     public java.lang.String JavaDoc getSize() {
811         return sizeToUse;
812     } /* getSize() */
813
814     /**
815      * Getter method for Type.
816      *
817      * @return java.lang.String
818      */

819     public java.lang.String JavaDoc getType() {
820         return typeToUse;
821     } /* getType() */
822
823     /**
824      * Getter Method for Value.
825      * Creation date: (12/29/2000 %r)
826      *
827      * @return java.lang.String
828      */

829     public java.lang.String JavaDoc getValue() {
830         return valueToUse;
831     } /* getValue() */
832
833     /**
834      * Setter method for maxlength
835      *
836      * @param newMaxlength java.lang.String
837      */

838     public void setMaxlength(java.lang.String JavaDoc newMaxlength) {
839         maxlength = newMaxlength;
840     } /* setMaxlength(java.lang.String) */
841
842
843     /**
844      * Sets the multiple value to use.
845      *
846      * @param newMultiple ??
847      */

848     public void setMultiple(java.lang.String JavaDoc newMultiple) {
849         multiple = newMultiple;
850     }
851
852     /**
853      * Insert the method's description here.
854      * Creation date: (12/29/2000 %r)
855      *
856      * @param newName java.lang.String
857      */

858     public void setName(java.lang.String JavaDoc newName) {
859         name = newName;
860     } /* setName(java.lang.String) */
861
862
863     public Input getInput() {
864         return oneInput;
865     }
866
867     /**
868      * Setter method for showlabel
869      *
870      * @param newShowlabel java.lang.String
871      */

872     public void setShowlabel(java.lang.String JavaDoc newShowlabel) {
873         showlabel = newShowlabel;
874     } /* setShowlabel(java.lang.String) */
875
876     /**
877      * Setter method for size
878      *
879      * @param newSize java.lang.String
880      */

881     public void setSize(java.lang.String JavaDoc newSize) {
882         size = newSize;
883     } /* setSize(java.lang.String) */
884
885     /**
886      * Setter method for type
887      *
888      * @param newType java.lang.String
889      */

890     public void setType(java.lang.String JavaDoc newType) {
891         type = newType;
892     } /* setType(java.lang.String) */
893
894
895     /**
896      * Setter method for value
897      *
898      * @param newValue java.lang.String
899      */

900     public void setValue(java.lang.String JavaDoc newValue) {
901         value = newValue;
902     } /* setValue(java.lang.String) */
903
904     
905     
906     /**
907      * Gets the cols
908      * @return Returns the cols.
909      */

910     public int getCols() {
911         return cols;
912     }
913     
914     /**
915      * Sets the cols
916      * @param cols The cols to set.
917      */

918     public void setCols(int cols) {
919         this.cols = cols;
920     }
921     
922     /**
923      * Gets the rows
924      * @return Returns the rows.
925      */

926     public int getRows() {
927         return rows;
928     }
929     
930     /**
931      * Sets the rows
932      * @param rows The rows to set.
933      */

934     public void setRows(int rows) {
935         this.rows = rows;
936     }
937     
938     /**
939      * Gets the style
940      * @return Returns the style.
941      */

942     public String JavaDoc getStyle() {
943         return style;
944     }
945     
946     /**
947      * Sets the style
948      * @param style The style to set.
949      */

950     public void setStyle(String JavaDoc style) {
951         this.style = style;
952     }
953     
954     /**
955      * Gets the styleClass
956      * @return Returns the styleClass.
957      */

958     public String JavaDoc getStyleClass() {
959         return styleClass;
960     }
961     
962     /**
963      * Sets the styleClass
964      * @param styleClass The styleClass to set.
965      */

966     public void setStyleClass(String JavaDoc styleClass) {
967         this.styleClass = styleClass;
968     }
969     
970     /**
971      * Gets the styleId
972      * @return Returns the styleId.
973      */

974     public String JavaDoc getStyleId() {
975         return styleId;
976     }
977     
978     /**
979      * Sets the styleId
980      * @param styleId The styleId to set.
981      */

982     public void setStyleId(String JavaDoc styleId) {
983         this.styleId = styleId;
984     }
985
986     
987     /**
988      * Gets the onclick
989      * @return Returns the onclick.
990      */

991     public String JavaDoc getOnclick() {
992         return onclick;
993     }
994     /**
995      * Sets the onclick
996      * @param onclick The onclick to set.
997      */

998     public void setOnclick(String JavaDoc onclick) {
999         this.onclick = onclick;
1000    }
1001    /**
1002     * Gets the ondblclick
1003     * @return Returns the ondblclick.
1004     */

1005    public String JavaDoc getOndblclick() {
1006        return ondblclick;
1007    }
1008    /**
1009     * Sets the ondblclick
1010     * @param ondblclick The ondblclick to set.
1011     */

1012    public void setOndblclick(String JavaDoc ondblclick) {
1013        this.ondblclick = ondblclick;
1014    }
1015    /**
1016     * Gets the onhelp
1017     * @return Returns the onhelp.
1018     */

1019    public String JavaDoc getOnhelp() {
1020        return onhelp;
1021    }
1022    /**
1023     * Sets the onhelp
1024     * @param onhelp The onhelp to set.
1025     */

1026    public void setOnhelp(String JavaDoc onhelp) {
1027        this.onhelp = onhelp;
1028    }
1029    /**
1030     * Gets the onkeydown
1031     * @return Returns the onkeydown.
1032     */

1033    public String JavaDoc getOnkeydown() {
1034        return onkeydown;
1035    }
1036    /**
1037     * Sets the onkeydown
1038     * @param onkeydown The onkeydown to set.
1039     */

1040    public void setOnkeydown(String JavaDoc onkeydown) {
1041        this.onkeydown = onkeydown;
1042    }
1043    /**
1044     * Gets the onkeypress
1045     * @return Returns the onkeypress.
1046     */

1047    public String JavaDoc getOnkeypress() {
1048        return onkeypress;
1049    }
1050    /**
1051     * Sets the onkeypress
1052     * @param onkeypress The onkeypress to set.
1053     */

1054    public void setOnkeypress(String JavaDoc onkeypress) {
1055        this.onkeypress = onkeypress;
1056    }
1057    /**
1058     * Gets the onkeyup
1059     * @return Returns the onkeyup.
1060     */

1061    public String JavaDoc getOnkeyup() {
1062        return onkeyup;
1063    }
1064    /**
1065     * Sets the onkeyup
1066     * @param onkeyup The onkeyup to set.
1067     */

1068    public void setOnkeyup(String JavaDoc onkeyup) {
1069        this.onkeyup = onkeyup;
1070    }
1071    /**
1072     * Gets the onmousedown
1073     * @return Returns the onmousedown.
1074     */

1075    public String JavaDoc getOnmousedown() {
1076        return onmousedown;
1077    }
1078    /**
1079     * Sets the onmousedown
1080     * @param onmousedown The onmousedown to set.
1081     */

1082    public void setOnmousedown(String JavaDoc onmousedown) {
1083        this.onmousedown = onmousedown;
1084    }
1085    /**
1086     * Gets the onmousemove
1087     * @return Returns the onmousemove.
1088     */

1089    public String JavaDoc getOnmousemove() {
1090        return onmousemove;
1091    }
1092    /**
1093     * Sets the onmousemove
1094     * @param onmousemove The onmousemove to set.
1095     */

1096    public void setOnmousemove(String JavaDoc onmousemove) {
1097        this.onmousemove = onmousemove;
1098    }
1099    /**
1100     * Gets the onmouseout
1101     * @return Returns the onmouseout.
1102     */

1103    public String JavaDoc getOnmouseout() {
1104        return onmouseout;
1105    }
1106    /**
1107     * Sets the onmouseout
1108     * @param onmouseout The onmouseout to set.
1109     */

1110    public void setOnmouseout(String JavaDoc onmouseout) {
1111        this.onmouseout = onmouseout;
1112    }
1113    /**
1114     * Gets the onmouseover
1115     * @return Returns the onmouseover.
1116     */

1117    public String JavaDoc getOnmouseover() {
1118        return onmouseover;
1119    }
1120    /**
1121     * Sets the onmouseover
1122     * @param onmouseover The onmouseover to set.
1123     */

1124    public void setOnmouseover(String JavaDoc onmouseover) {
1125        this.onmouseover = onmouseover;
1126    }
1127    /**
1128     * Gets the onmouseup
1129     * @return Returns the onmouseup.
1130     */

1131    public String JavaDoc getOnmouseup() {
1132        return onmouseup;
1133    }
1134    /**
1135     * Sets the onmouseup
1136     * @param onmouseup The onmouseup to set.
1137     */

1138    public void setOnmouseup(String JavaDoc onmouseup) {
1139        this.onmouseup = onmouseup;
1140    }
1141} /* InputTag */
1142
Popular Tags