KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jresearch > gossip > tags > NumericOptionsTag


1 /*
2  * $$Id$$
3  *
4  * ***** BEGIN LICENSE BLOCK *****
5  * The contents of this file are subject to the Mozilla Public License
6  * Version 1.1 (the "License"); you may not use this file except in
7  * compliance with the License. You may obtain a copy of the License
8  * at http://www.mozilla.org/MPL/
9  *
10  * Software distributed under the License is distributed on an "AS IS"
11  * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
12  * the License for the specific language governing rights and
13  * limitations under the License.
14  *
15  * The Original Code is JGossip forum code.
16  *
17  * The Initial Developer of the Original Code is the JResearch, Org.
18  * Portions created by the Initial Developer are Copyright (C) 2004
19  * the Initial Developer. All Rights Reserved.
20  *
21  * Contributor(s):
22  * Dmitry Belov <bel@jresearch.org>
23  *
24  * ***** END LICENSE BLOCK ***** */

25 /*
26  * Created on 04.06.2003
27  *
28  */

29 package org.jresearch.gossip.tags;
30
31 import java.util.ArrayList JavaDoc;
32
33 import javax.servlet.jsp.JspException JavaDoc;
34 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
35
36 /**
37  * DOCUMENT ME!
38  *
39  * @author Bel
40  */

41 public class NumericOptionsTag extends TagSupport JavaDoc {
42     private int startValue;
43
44     private int endValue;
45
46     private int step = 1;
47
48     /**
49      * DOCUMENT ME!
50      *
51      * @return DOCUMENT ME!
52      *
53      * @throws JspException
54      * DOCUMENT ME!
55      */

56     public int doStartTag() throws JspException JavaDoc {
57         try {
58             ArrayList JavaDoc options = new ArrayList JavaDoc();
59
60             if (startValue < endValue) {
61                 while (startValue <= endValue) {
62                     OptionBean option = new OptionBean();
63                     option.setLabelProperty(startValue + "");
64                     option.setProperty(startValue + "");
65                     options.add(option);
66                     startValue += step;
67                 }
68             } else {
69                 while (startValue >= endValue) {
70                     OptionBean option = new OptionBean();
71                     option.setLabelProperty(startValue + "");
72                     option.setProperty(startValue + "");
73                     options.add(option);
74                     startValue -= step;
75                 }
76             }
77
78             pageContext.setAttribute("NumericOptions", options);
79         } catch (Exception JavaDoc ex) {
80             throw new JspException JavaDoc("error in NumericOptionsTag tag:", ex);
81         }
82
83         return (SKIP_BODY);
84     }
85
86     /**
87      * DOCUMENT ME!
88      *
89      * @param i
90      */

91     public void setEndValue(int i) {
92         endValue = i;
93     }
94
95     /**
96      * DOCUMENT ME!
97      *
98      * @param i
99      */

100     public void setStartValue(int i) {
101         startValue = i;
102     }
103
104     /**
105      * DOCUMENT ME!
106      *
107      * @param i
108      */

109     public void setStep(int i) {
110         step = i;
111     }
112 }
113
Popular Tags