Source code: com/openwave/oui/waomelements/Form.java
1 package com.openwave.oui.waomelements;
2
3 import com.openwave.oui.framework.*;
4 import com.sun.java.util.collections.*;
5
6 /**
7 * At times, applications require users to insert several pieces of information. In these cases you
8 * should use a form. There are two kinds of forms: elective forms and wizards. Elective forms
9 * present multiple entry fields for the user to fill in the same card while wizards collect
10 * information from users, one step at the time. <br/>
11 * If you wonder which kind of form offers better usability, the answer is: "it depends". Users of
12 * the Nokia 7110 find elective forms intuitive (in spite of the high number of clicks required
13 * to operate them), while users of UP.Browser find wizards more intuitive. <br/>
14 * The Form object will let you define a form that will render as the most usable construct on
15 * each device. <br/>
16 * Creation date: (4/4/2001 12:57:36 PM)
17 * @author: Lars Gunder Knudsen
18 */
19 public class Form extends AbsCard {
20 protected String longTitle = null;
21 private boolean formIsElectiveOnUPText = false;
22
23 private final static long serialVersionUID = 5961395478519968169L;
24 /**
25 * Card constructor.
26 * Sets <code>waomElementName</code> = "Card"
27 */
28 Form() {
29 super();
30 //waomElementName = "Form";
31 setWaomElementName("Form");
32 }
33
34 /**
35 * Card constructor. Sets <code>waomElementName</code> = "Card"
36 * @param id Form ID
37 * @param shortTitle Card title
38 */
39 public Form(String id, String shortTitle) {
40 super();
41 //waomElementName = "Form";
42 setWaomElementName("Form");
43 this.shortTitle = shortTitle;
44 setIdValue(id);
45 }
46
47 /**
48 * Insert the method's description here.
49 * Creation date: (4/4/2001 2:00:59 PM)
50 */
51 public String getId() {
52 return getIdValue();
53 }
54 /**
55 * Sets card ID.
56 * Creation date: (4/4/2001 2:00:59 PM)
57 * @param id Card ID
58 */
59 public void setId(String id) {
60 setIdValue(id);
61 }
62
63 /**
64 * This is the short form for defining a Secondary path activity. It assumes that a URL is all
65 * you need to move on. If you need to pass along some values to the server by means of postfields,
66 * you will need to use the addSecondaryPathTask(). <br/>
67 * This method will cause navigation to be supported in the form of a hyperlink on Nokia phones
68 * and through softkeys on UP.Browser.
69 */
70 public void addSecondaryPath(String URL, String shortName, String longName) {
71 // pathURL.add(new Path(Path.SECONDARY, URL, shortName, longName));
72 //addElement(new Path(Path.SECONDARY, URL, shortName, longName));
73 super.addElement(new PathTask(PathTask.SECONDARY, new Task("go", URL), shortName, longName));
74
75 }
76
77 /**
78 * Define a side-path activity. This method will cause navigation to be supported in the option
79 * menu on Nokia phones and through softkeys on UP.Browser.
80 */
81 public void addSidePath(String URL, String shortName, String longName) {
82 // pathURL.add(new Path(Path.SIDE, URL, shortName, longName));
83 //addElement(new Path(Path.SIDE, URL, shortName, longName));
84 super.addElement(new PathTask(PathTask.SIDE, new Task("go", URL), shortName, longName));
85 }
86
87
88 /**
89 * Add an element to the form
90 *
91 */
92 public void addElement(WaomElement element) {
93 //System.out.println("Adding " + element.getWaomElementName());
94 if (!isInParagraph && !element.isParagraph() && !element.isOnevent() && !element.isTimer())
95 beginParagraph();
96 super.addElement(element);
97 if(isInParagraph){
98 endParagraph();
99 }
100 }
101
102
103 public void addMenu(Menu menu) {
104 addElement(menu);
105 }
106
107
108 /**
109 * This is the short form for defining a Secondary path activity.
110 * It assumes that a URL is all you need to move on. If you need to pass along some values
111 * to the server by means of postfields, you will need to use the addSecondaryPathTask().
112 * This method will cause navigation to be supported in the form of a hyperlink on Nokia
113 * phones and through softkeys on UP.Browser.
114 */
115 public void addSecondaryPath(String URL, String shortName) {
116 addSecondaryPath(URL, shortName, shortName);
117 }
118
119
120 /**
121 * This is the short form for defining a Secondary path activity.
122 */
123 public void addSecondaryPathTask(AbsTask absTask, String shortName) {
124 addSecondaryPathTask(absTask, shortName, shortName);
125 }
126
127
128 /**
129 * As corresponding method above. Activity can be a task.
130 */
131 public void addSecondaryPathTask(AbsTask absTask, String shortName, String longName) {
132 super.addElement(new PathTask(PathTask.SECONDARY, absTask, shortName, longName));
133 }
134
135
136 /**
137 * Define a side-path activity.
138 * This method will cause navigation to be supported in the option menu on Nokia
139 * phones and through softkeys on UP.Browser.
140 */
141
142 public void addSidePath(String URL, String shortName) {
143 addSidePath(URL, shortName, shortName);
144 }
145
146
147 /**
148 * Define a side-path activity.
149 */
150 public void addSidePathTask(AbsTask absTask, String shortName) {
151 addSidePathTask(absTask, shortName, shortName);
152 }
153
154
155 /**
156 * As corresponding method above. Activity can be a task.
157 */
158 public void addSidePathTask(AbsTask absTask, String shortName, String longName) {
159 super.addElement(new PathTask(PathTask.SIDE, absTask, shortName, longName));
160 }
161
162
163 public boolean isForm(){
164 return true;
165 }
166
167
168 public boolean isFormElectiveOnUPText() {
169 return this.formIsElectiveOnUPText;
170 }
171
172
173 /**
174 * Forces the UP.Browser to show the form as an elective form.
175 *
176 */
177 public void makeFormElectiveOnUPText() {
178 this.formIsElectiveOnUPText = true;
179 }
180
181
182 /**
183 * This is the short form for defining a main path activity.
184 * It assumes that a URL is all you need to move on. If you need to pass along some values
185 * to the server by means of postfields, you will need to use the setPrimaryPathTask().<br/>
186 * This method will cause navigation to be supported in the form of a hyperlink on Nokia
187 * phones and through softkeys on UP.Browser.<br/>
188 *
189 */
190
191 public void setPrimaryPath(String URL, String shortName) {
192 setPrimaryPath(URL, shortName, shortName);
193 }
194
195
196 /**
197 * This is the short form for defining a main path activity. It assumes that a URL is all you need
198 * to move on. If you need to pass along some values to the server by means of postfields, you will
199 * need to use the setPrimaryPathTask(). <br/>
200 * This method will cause navigation to be supported in the form of a hyperlink on Nokia phones and
201 * through softkeys on UP.Browser.
202 */
203 public void setPrimaryPath(String URL, String shortName, String longName) {
204 super.addElement(new PathTask(PathTask.PRIMARY, new Task("go", URL, "get"), shortName, longName));
205 }
206
207
208 /**
209 * This is the short form for defining a main path activity.
210 *
211 */
212
213 public void setPrimaryPathTask(
214 AbsTask absTask,
215 String shortName) {
216 setPrimaryPathTask(absTask,shortName,shortName);
217 }
218
219
220 /**
221 * Activity can be any task.
222 */
223 public void setPrimaryPathTask(AbsTask absTask, String shortName, String longName) {
224 super.addElement(new PathTask(PathTask.PRIMARY, absTask, shortName, longName));
225 }
226
227
228 public void setTaskMenu(TaskMenu taskMenu){
229 this.addElement(taskMenu);
230 }
231
232
233 public void visit(WaomVisitor wv){
234 wv.visit(this);
235 }
236 }