KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > ofbiz > widget > html > HtmlFormRenderer


1 /*
2  * $Id: HtmlFormRenderer.java 7100 2006-03-29 00:26:54Z jonesde $
3  *
4  * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
5  *
6  * Permission is hereby granted, free of charge, to any person obtaining a
7  * copy of this software and associated documentation files (the "Software"),
8  * to deal in the Software without restriction, including without limitation
9  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10  * and/or sell copies of the Software, and to permit persons to whom the
11  * Software is furnished to do so, subject to the following conditions:
12  *
13  * The above copyright notice and this permission notice shall be included
14  * in all copies or substantial portions of the Software.
15  *
16  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
19  * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20  * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
21  * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
22  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23  */

24 package org.ofbiz.widget.html;
25
26 import java.util.Iterator JavaDoc;
27 import java.util.List JavaDoc;
28 import java.util.Locale JavaDoc;
29 import java.util.Map JavaDoc;
30 import java.util.HashSet JavaDoc;
31 import java.util.Calendar JavaDoc;
32 import java.sql.Timestamp JavaDoc;
33
34 import javax.servlet.ServletContext JavaDoc;
35 import javax.servlet.http.HttpServletRequest JavaDoc;
36 import javax.servlet.http.HttpServletResponse JavaDoc;
37
38 import org.ofbiz.base.util.Debug;
39 import org.ofbiz.base.util.UtilHttp;
40 import org.ofbiz.base.util.UtilProperties;
41 import org.ofbiz.base.util.UtilValidate;
42 import org.ofbiz.base.util.string.FlexibleStringExpander;
43 import org.ofbiz.webapp.control.RequestHandler;
44 import org.ofbiz.webapp.taglib.ContentUrlTag;
45 import org.ofbiz.widget.WidgetWorker;
46 import org.ofbiz.widget.form.FormStringRenderer;
47 import org.ofbiz.widget.form.ModelForm;
48 import org.ofbiz.widget.form.ModelFormField;
49 import org.ofbiz.widget.form.ModelFormField.CheckField;
50 import org.ofbiz.widget.form.ModelFormField.DateFindField;
51 import org.ofbiz.widget.form.ModelFormField.DateTimeField;
52 import org.ofbiz.widget.form.ModelFormField.DisplayEntityField;
53 import org.ofbiz.widget.form.ModelFormField.DisplayField;
54 import org.ofbiz.widget.form.ModelFormField.DropDownField;
55 import org.ofbiz.widget.form.ModelFormField.FileField;
56 import org.ofbiz.widget.form.ModelFormField.HiddenField;
57 import org.ofbiz.widget.form.ModelFormField.HyperlinkField;
58 import org.ofbiz.widget.form.ModelFormField.IgnoredField;
59 import org.ofbiz.widget.form.ModelFormField.ImageField;
60 import org.ofbiz.widget.form.ModelFormField.LookupField;
61 import org.ofbiz.widget.form.ModelFormField.PasswordField;
62 import org.ofbiz.widget.form.ModelFormField.RadioField;
63 import org.ofbiz.widget.form.ModelFormField.RangeFindField;
64 import org.ofbiz.widget.form.ModelFormField.ResetField;
65 import org.ofbiz.widget.form.ModelFormField.SubmitField;
66 import org.ofbiz.widget.form.ModelFormField.TextField;
67 import org.ofbiz.widget.form.ModelFormField.TextFindField;
68 import org.ofbiz.widget.form.ModelFormField.TextareaField;
69
70
71 /**
72  * Widget Library - HTML Form Renderer implementation
73  *
74  * @author <a HREF="mailto:jonesde@ofbiz.org">David E. Jones</a>
75  * @author <a HREF="mailto:byersa@automationgroups.com">Al Byers</a>
76  * @version $Rev: 7100 $
77  * @since 2.2
78  */

79 public class HtmlFormRenderer implements FormStringRenderer {
80
81     public static final String JavaDoc module = HtmlFormRenderer.class.getName();
82     
83     HttpServletRequest JavaDoc request;
84     HttpServletResponse JavaDoc response;
85     protected String JavaDoc lastFieldGroupId = "";
86
87     protected HtmlFormRenderer() {}
88
89     public HtmlFormRenderer(HttpServletRequest JavaDoc request, HttpServletResponse JavaDoc response) {
90         this.request = request;
91         this.response = response;
92     }
93
94     public void appendWhitespace(StringBuffer JavaDoc buffer) {
95         // appending line ends for now, but this could be replaced with a simple space or something
96
buffer.append("\r\n");
97         //buffer.append(' ');
98
}
99
100     public void appendOfbizUrl(StringBuffer JavaDoc buffer, String JavaDoc location) {
101         ServletContext JavaDoc ctx = (ServletContext JavaDoc) this.request.getAttribute("servletContext");
102         RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
103         // make and append the link
104
buffer.append(rh.makeLink(this.request, this.response, location));
105     }
106
107     public void appendContentUrl(StringBuffer JavaDoc buffer, String JavaDoc location) {
108         ContentUrlTag.appendContentPrefix(this.request, buffer);
109         buffer.append(location);
110     }
111
112     public void appendTooltip(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField) {
113         // render the tooltip, in other methods too
114
String JavaDoc tooltip = modelFormField.getTooltip(context);
115         if (UtilValidate.isNotEmpty(tooltip)) {
116             buffer.append("<span");
117             String JavaDoc tooltipStyle = modelFormField.getTooltipStyle();
118             if (UtilValidate.isNotEmpty(tooltipStyle)) {
119                 buffer.append(" class=\"");
120                 buffer.append(tooltipStyle);
121                 buffer.append("\"");
122             }
123             buffer.append("> -[");
124             buffer.append(tooltip);
125             buffer.append("]- </span>");
126         }
127     }
128
129     public void addAstericks(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField) {
130            
131         boolean requiredField = modelFormField.getRequiredField();
132         if (requiredField) {
133             String JavaDoc requiredStyle = modelFormField.getRequiredFieldStyle();
134             
135             if (UtilValidate.isEmpty(requiredStyle)) {
136                buffer.append("*");
137             }
138         }
139         return;
140     }
141     
142     /* (non-Javadoc)
143      * @see org.ofbiz.widget.form.FormStringRenderer#renderDisplayField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.DisplayField)
144      */

145     public void renderDisplayField(StringBuffer JavaDoc buffer, Map JavaDoc context, DisplayField displayField) {
146         ModelFormField modelFormField = displayField.getModelFormField();
147
148         buffer.append("<span");
149
150         if (UtilValidate.isNotEmpty(modelFormField.getWidgetStyle())) {
151             buffer.append(" class=\"");
152             buffer.append(modelFormField.getWidgetStyle());
153             buffer.append("\"");
154         }
155
156         // add a style of red if this is a date/time field and redWhen is true
157
if (modelFormField.shouldBeRed(context)) {
158             buffer.append(" style=\"color: red;\"");
159         }
160
161         buffer.append(">");
162         buffer.append(displayField.getDescription(context));
163         buffer.append("</span>");
164
165         if (displayField instanceof DisplayEntityField) {
166             this.makeHyperlinkString(buffer, ((DisplayEntityField) displayField).getSubHyperlink(), context);
167         }
168         
169         this.appendTooltip(buffer, context, modelFormField);
170
171         this.appendWhitespace(buffer);
172     }
173
174     /* (non-Javadoc)
175      * @see org.ofbiz.widget.form.FormStringRenderer#renderHyperlinkField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.HyperlinkField)
176      */

177     public void renderHyperlinkField(StringBuffer JavaDoc buffer, Map JavaDoc context, HyperlinkField hyperlinkField) {
178         ModelFormField modelFormField = hyperlinkField.getModelFormField();
179         this.makeHyperlinkString(
180             buffer,
181             modelFormField.getWidgetStyle(),
182             hyperlinkField.getTargetType(),
183             hyperlinkField.getTarget(context),
184             hyperlinkField.getDescription(context),
185             hyperlinkField.getTargetWindow(context));
186         this.appendTooltip(buffer, context, modelFormField);
187         this.appendWhitespace(buffer);
188     }
189
190     public void makeHyperlinkString(StringBuffer JavaDoc buffer, ModelFormField.SubHyperlink subHyperlink, Map JavaDoc context) {
191         if (subHyperlink == null) {
192             return;
193         }
194         if (subHyperlink.shouldUse(context)) {
195             buffer.append(' ');
196             this.makeHyperlinkString(
197                 buffer,
198                 subHyperlink.getLinkStyle(),
199                 subHyperlink.getTargetType(),
200                 subHyperlink.getTarget(context),
201                 subHyperlink.getDescription(context),
202                 subHyperlink.getTargetWindow(context));
203         }
204     }
205
206     public void makeHyperlinkString(StringBuffer JavaDoc buffer, String JavaDoc linkStyle, String JavaDoc targetType, String JavaDoc target, String JavaDoc description, String JavaDoc targetWindow) {
207         Map JavaDoc context = null;
208         WidgetWorker.makeHyperlinkString(buffer, linkStyle, targetType, target, description, this.request, this.response, context, targetWindow);
209     }
210
211     /* (non-Javadoc)
212      * @see org.ofbiz.widget.form.FormStringRenderer#renderTextField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.TextField)
213      */

214     public void renderTextField(StringBuffer JavaDoc buffer, Map JavaDoc context, TextField textField) {
215         ModelFormField modelFormField = textField.getModelFormField();
216
217         buffer.append("<input type=\"text\"");
218
219         String JavaDoc className = modelFormField.getWidgetStyle();
220         if (UtilValidate.isNotEmpty(className)) {
221             buffer.append(" class=\"");
222             buffer.append(className);
223             buffer.append('"');
224         }
225
226         // add a style of red if this is a date/time field and redWhen is true
227
if (modelFormField.shouldBeRed(context)) {
228             buffer.append(" style=\"color: red;\"");
229         }
230
231         buffer.append(" name=\"");
232         buffer.append(modelFormField.getParameterName(context));
233         buffer.append('"');
234
235         String JavaDoc value = modelFormField.getEntry(context, textField.getDefaultValue(context));
236         if (UtilValidate.isNotEmpty(value)) {
237             buffer.append(" value=\"");
238             buffer.append(value);
239             buffer.append('"');
240         }
241
242         buffer.append(" size=\"");
243         buffer.append(textField.getSize());
244         buffer.append('"');
245
246         Integer JavaDoc maxlength = textField.getMaxlength();
247         if (maxlength != null) {
248             buffer.append(" maxlength=\"");
249             buffer.append(maxlength.intValue());
250             buffer.append('"');
251         }
252
253         String JavaDoc idName = modelFormField.getIdName();
254         if (UtilValidate.isNotEmpty(idName)) {
255             buffer.append(" id=\"");
256             buffer.append(idName);
257             buffer.append('"');
258         }
259
260         String JavaDoc event = modelFormField.getEvent();
261         String JavaDoc action = modelFormField.getAction();
262         if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
263             buffer.append(" ");
264             buffer.append(event);
265             buffer.append("=\"");
266             buffer.append(action);
267             buffer.append('"');
268         }
269
270         buffer.append("/>");
271         
272         this.addAstericks(buffer, context, modelFormField);
273
274         this.makeHyperlinkString(buffer, textField.getSubHyperlink(), context);
275
276         this.appendTooltip(buffer, context, modelFormField);
277
278         this.appendWhitespace(buffer);
279     }
280
281     /* (non-Javadoc)
282      * @see org.ofbiz.widget.form.FormStringRenderer#renderTextareaField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.TextareaField)
283      */

284     public void renderTextareaField(StringBuffer JavaDoc buffer, Map JavaDoc context, TextareaField textareaField) {
285         ModelFormField modelFormField = textareaField.getModelFormField();
286
287         buffer.append("<textarea");
288
289         String JavaDoc className = modelFormField.getWidgetStyle();
290         if (UtilValidate.isNotEmpty(className)) {
291             buffer.append(" class=\"");
292             buffer.append(className);
293             buffer.append('"');
294         } else {
295             buffer.append(" class=\"textAreaBox\"");
296         }
297
298         buffer.append(" name=\"");
299         buffer.append(modelFormField.getParameterName(context));
300         buffer.append('"');
301
302         buffer.append(" cols=\"");
303         buffer.append(textareaField.getCols());
304         buffer.append('"');
305
306         buffer.append(" rows=\"");
307         buffer.append(textareaField.getRows());
308         buffer.append('"');
309
310         String JavaDoc idName = modelFormField.getIdName();
311         if (UtilValidate.isNotEmpty(idName)) {
312             buffer.append(" id=\"");
313             buffer.append(idName);
314             buffer.append('"');
315         } else if (textareaField.getVisualEditorEnable()) {
316             buffer.append(" id=\"");
317             buffer.append("htmlEditArea");
318             buffer.append('"');
319         }
320  
321         buffer.append('>');
322
323         String JavaDoc value = modelFormField.getEntry(context, textareaField.getDefaultValue(context));
324         if (UtilValidate.isNotEmpty(value)) {
325             buffer.append(value);
326         }
327
328         buffer.append("</textarea>");
329         
330         if (textareaField.getVisualEditorEnable()) {
331             buffer.append("<script language=\"javascript\" SRC=\"/images/htmledit/whizzywig.js\" type=\"text/javascript\"></script>");
332             buffer.append("<script language=\"javascript\" type=\"text/javascript\"> buttonPath = \"/images/htmledit/\"; cssFile=\"/images/htmledit/simple.css\";makeWhizzyWig(\"");
333             if (UtilValidate.isNotEmpty(idName)) {
334                 buffer.append(idName);
335             } else {
336                 buffer.append("htmlEditArea");
337             }
338             buffer.append("\",\"");
339             String JavaDoc buttons = textareaField.getVisualEditorButtons(context);
340             if (UtilValidate.isNotEmpty(buttons)) {
341                 buffer.append(buttons);
342             } else {
343                 buffer.append("all");
344             }
345             buffer.append("\") </script>");
346         }
347
348         this.addAstericks(buffer, context, modelFormField);
349
350         this.appendTooltip(buffer, context, modelFormField);
351
352         this.appendWhitespace(buffer);
353     }
354
355     /* (non-Javadoc)
356      * @see org.ofbiz.widget.form.FormStringRenderer#renderDateTimeField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.DateTimeField)
357      */

358     public void renderDateTimeField(StringBuffer JavaDoc buffer, Map JavaDoc context, DateTimeField dateTimeField) {
359         ModelFormField modelFormField = dateTimeField.getModelFormField();
360         String JavaDoc paramName = modelFormField.getParameterName(context);
361         String JavaDoc defaultDateTimeString = dateTimeField.getDefaultDateTimeString(context);
362
363         // whether the date field is short form, yyyy-mm-dd
364
boolean shortDateInput = ("date".equals(dateTimeField.getType()) || "time-dropdown".equals(dateTimeField.getInputMethod()) ? true : false);
365
366         buffer.append("<input type=\"text\"");
367
368         String JavaDoc className = modelFormField.getWidgetStyle();
369         if (UtilValidate.isNotEmpty(className)) {
370             buffer.append(" class=\"");
371             buffer.append(className);
372             buffer.append('"');
373         }
374
375         // add a style of red if this is a date/time field and redWhen is true
376
if (modelFormField.shouldBeRed(context)) {
377             buffer.append(" style=\"color: red;\"");
378         }
379
380         buffer.append(" name=\"");
381         if ("time-dropdown".equals(dateTimeField.getInputMethod())) {
382             buffer.append(UtilHttp.makeCompositeParam(paramName, "date"));
383         } else {
384             buffer.append(paramName);
385         }
386         buffer.append('"');
387
388         String JavaDoc value = modelFormField.getEntry(context, dateTimeField.getDefaultValue(context));
389         if (UtilValidate.isNotEmpty(value)) {
390             buffer.append(" value=\"");
391             if ("date".equals(dateTimeField.getType()) && value.length()>=10) {
392                 value = value.substring(0, 10);
393             } else if ("time".equals(dateTimeField.getType()) && value.length()>=16) {
394                 value = value.substring(0, 16);
395             }
396
397             buffer.append(value);
398             buffer.append('"');
399         }
400
401         // the default values for a timestamp
402
int size = 25;
403         int maxlength = 30;
404
405         if (shortDateInput) {
406             size = 10;
407             maxlength = 10;
408         } else if ("time".equals(dateTimeField.getType())) {
409             size = 16;
410             maxlength = 16;
411         }
412
413         buffer.append(" size=\"");
414         buffer.append(size);
415         buffer.append('"');
416
417         buffer.append(" maxlength=\"");
418         buffer.append(maxlength);
419         buffer.append('"');
420
421         String JavaDoc idName = modelFormField.getIdName();
422         if (UtilValidate.isNotEmpty(idName)) {
423             buffer.append(" id=\"");
424             buffer.append(idName);
425             buffer.append('"');
426         }
427
428         buffer.append("/>");
429
430         // add calendar pop-up button and seed data IF this is not a "time" type date-time
431
if (!"time".equals(dateTimeField.getType())) {
432             if (shortDateInput) {
433                 buffer.append("<a HREF=\"javascript:call_cal_notime(document.");
434             } else {
435                 buffer.append("<a HREF=\"javascript:call_cal(document.");
436             }
437             buffer.append(modelFormField.getModelForm().getCurrentFormName(context));
438             buffer.append('.');
439             if ("time-dropdown".equals(dateTimeField.getInputMethod()))
440                 buffer.append(UtilHttp.makeCompositeParam(paramName, "date"));
441             else {
442                 buffer.append(paramName);
443             }
444             buffer.append(",'");
445             buffer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, defaultDateTimeString)));
446             buffer.append("');\">");
447             buffer.append("<img SRC=\"");
448             this.appendContentUrl(buffer, "/content/images/cal.gif");
449             buffer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"Calendar\"/></a>");
450         }
451
452         // if we have an input method of time-dropdown, then render two dropdowns
453
if ("time-dropdown".equals(dateTimeField.getInputMethod())) {
454             String JavaDoc classString = (className != null ? " class=\"" + className + "\" " : "");
455             boolean isTwelveHour = "12".equals(dateTimeField.getClock());
456
457             // set the Calendar to the default time of the form or now()
458
Calendar JavaDoc cal = null;
459             try {
460                 Timestamp JavaDoc defaultTimestamp = Timestamp.valueOf(modelFormField.getEntry(context, defaultDateTimeString));
461                 cal = Calendar.getInstance();
462                 cal.setTime(defaultTimestamp);
463             } catch (IllegalArgumentException JavaDoc e) {
464                 Debug.logWarning("Form widget field [" + paramName + "] with input-method=\"time-dropdown\" was not able to understand the default time ["
465                         + defaultDateTimeString + "]. The parsing error was: " + e.getMessage(), module);
466             }
467
468             // write the select for hours
469
buffer.append("&nbsp;<select name=\"").append(UtilHttp.makeCompositeParam(paramName, "hour")).append("\"");
470             buffer.append(classString).append(">");
471
472             // keep the two cases separate because it's hard to unerstand a combined loop
473
if (isTwelveHour) {
474                 for (int i = 1; i <= 12; i++) {
475                     buffer.append("<option value=\"").append(i).append("\"");
476                     if (cal != null) {
477                         int hour = cal.get(Calendar.HOUR_OF_DAY);
478                         if (hour == 0) hour = 12;
479                         if (hour > 12) hour -= 12;
480                         if (i == hour) buffer.append(" selected");
481                     }
482                     buffer.append(">").append(i).append("</option>");
483                 }
484             } else {
485                 for (int i = 0; i < 24; i++) {
486                     buffer.append("<option value=\"").append(i).append("\"");
487                     if (cal != null && i == cal.get(Calendar.HOUR_OF_DAY)) {
488                         buffer.append(" selected");
489                     }
490                     buffer.append(">").append(i).append("</option>");
491                 }
492             }
493             
494             // write the select for minutes
495
buffer.append("</select>:<select name=\"");
496             buffer.append(UtilHttp.makeCompositeParam(paramName, "minutes")).append("\"");
497             buffer.append(classString).append(">");
498             for (int i = 0; i < 60; i++) {
499                 buffer.append("<option value=\"").append(i).append("\"");
500                 if (cal != null && i == cal.get(Calendar.MINUTE)) {
501                     buffer.append(" selected");
502                 }
503                 buffer.append(">").append(i).append("</option>");
504             }
505             buffer.append("</select>");
506
507             // if 12 hour clock, write the AM/PM selector
508
if (isTwelveHour) {
509                 String JavaDoc amSelected = ((cal != null && cal.get(Calendar.AM_PM) == Calendar.AM) ? "selected" : "");
510                 String JavaDoc pmSelected = ((cal != null && cal.get(Calendar.AM_PM) == Calendar.PM) ? "selected" : "");
511                 buffer.append("<select name=\"").append(UtilHttp.makeCompositeParam(paramName, "ampm")).append("\"");
512                 buffer.append(classString).append(">");
513                 buffer.append("<option value=\"").append("AM").append("\" ").append(amSelected).append(">AM</option>");
514                 buffer.append("<option value=\"").append("PM").append("\" ").append(pmSelected).append(">PM</option>");
515                 buffer.append("</select>");
516             }
517
518             // create a hidden field for the composite type, which is a Timestamp
519
buffer.append("<input type=\"hidden\" name=\"");
520             buffer.append(UtilHttp.makeCompositeParam(paramName, "compositeType"));
521             buffer.append("\" value=\"Timestamp\">");
522         }
523
524         this.appendTooltip(buffer, context, modelFormField);
525
526         this.appendWhitespace(buffer);
527     }
528
529     /* (non-Javadoc)
530      * @see org.ofbiz.widget.form.FormStringRenderer#renderDropDownField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.DropDownField)
531      */

532     public void renderDropDownField(StringBuffer JavaDoc buffer, Map JavaDoc context, DropDownField dropDownField) {
533         ModelFormField modelFormField = dropDownField.getModelFormField();
534         ModelForm modelForm = modelFormField.getModelForm();
535
536         String JavaDoc event = modelFormField.getEvent();
537         String JavaDoc action = modelFormField.getAction();
538
539         buffer.append("<select");
540
541         String JavaDoc className = modelFormField.getWidgetStyle();
542         if (UtilValidate.isNotEmpty(className)) {
543             buffer.append(" class=\"");
544             buffer.append(className);
545             buffer.append('"');
546         }
547
548         buffer.append(" name=\"");
549         buffer.append(modelFormField.getParameterName(context));
550         buffer.append('"');
551
552         String JavaDoc idName = modelFormField.getIdName();
553         if (UtilValidate.isNotEmpty(idName)) {
554             buffer.append(" id=\"");
555             buffer.append(idName);
556             buffer.append('"');
557         }
558         
559         int otherFieldSize = dropDownField.getOtherFieldSize();
560         String JavaDoc otherFieldName = dropDownField.getParameterNameOther(context);
561         if (otherFieldSize > 0) {
562             //buffer.append(" onchange=\"alert('ONCHANGE, process_choice:' + process_choice)\"");
563
//buffer.append(" onchange='test_js()' ");
564
buffer.append(" onchange=\"process_choice(this,document.");
565             buffer.append(modelForm.getName());
566             buffer.append(".");
567             buffer.append(otherFieldName);
568             buffer.append(")\" ");
569             /*
570             */

571         }
572
573
574         if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
575             buffer.append(" ");
576             buffer.append(event);
577             buffer.append("=\"");
578             buffer.append(action);
579             buffer.append('"');
580         }
581
582         buffer.append(" size=\"1\">");
583
584         String JavaDoc currentValue = modelFormField.getEntry(context);
585         List JavaDoc allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator());
586
587         // if the current value should go first, stick it in
588
if (UtilValidate.isNotEmpty(currentValue) && "first-in-list".equals(dropDownField.getCurrent())) {
589             buffer.append("<option");
590             buffer.append(" selected=\"selected\"");
591             buffer.append(" value=\"");
592             buffer.append(currentValue);
593             buffer.append("\">");
594             String JavaDoc explicitDescription = dropDownField.getCurrentDescription(context);
595             if (UtilValidate.isNotEmpty(explicitDescription)) {
596                 buffer.append(explicitDescription);
597             } else {
598                 buffer.append(ModelFormField.FieldInfoWithOptions.getDescriptionForOptionKey(currentValue, allOptionValues));
599             }
600             buffer.append("</option>");
601
602             // add a "separator" option
603
buffer.append("<option value=\"");
604             buffer.append(currentValue);
605             buffer.append("\">---</option>");
606         }
607
608         // if allow empty is true, add an empty option
609
if (dropDownField.isAllowEmpty()) {
610             buffer.append("<option value=\"\">&nbsp;</option>");
611         }
612
613         // list out all options according to the option list
614
Iterator JavaDoc optionValueIter = allOptionValues.iterator();
615         while (optionValueIter.hasNext()) {
616             ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next();
617             String JavaDoc noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context);
618             buffer.append("<option");
619             // if current value should be selected in the list, select it
620
if (UtilValidate.isNotEmpty(currentValue) && currentValue.equals(optionValue.getKey()) && "selected".equals(dropDownField.getCurrent())) {
621                 buffer.append(" selected=\"selected\"");
622             } else if (UtilValidate.isEmpty(currentValue) && noCurrentSelectedKey != null && noCurrentSelectedKey.equals(optionValue.getKey())) {
623                 buffer.append(" selected=\"selected\"");
624             }
625             buffer.append(" value=\"");
626             buffer.append(optionValue.getKey());
627             buffer.append("\">");
628             buffer.append(optionValue.getDescription());
629             buffer.append("</option>");
630         }
631
632         buffer.append("</select>");
633
634         // Adapted from work by Yucca Korpela
635
// http://www.cs.tut.fi/~jkorpela/forms/combo.html
636
if (otherFieldSize > 0) {
637         
638             String JavaDoc fieldName = modelFormField.getParameterName(context);
639             Map JavaDoc dataMap = modelFormField.getMap(context);
640             if (dataMap == null) {
641                 dataMap = context;
642             }
643             Object JavaDoc otherValueObj = dataMap.get(otherFieldName);
644             String JavaDoc otherValue = (otherValueObj == null) ? "" : otherValueObj.toString();
645             
646             buffer.append("<noscript>");
647             buffer.append("<input type='text' name='");
648             buffer.append(otherFieldName);
649             buffer.append("'/> ");
650             buffer.append("</noscript>");
651             buffer.append("\n<script type='text/javascript' language='JavaScript'><!--");
652             buffer.append("\ndisa = ' disabled';");
653             buffer.append("\nif(other_choice(document.");
654             buffer.append(modelForm.getName());
655             buffer.append(".");
656             buffer.append(fieldName);
657             buffer.append(")) disa = '';");
658             buffer.append("\ndocument.write(\"<input type=");
659             buffer.append("'text' name='");
660             buffer.append(otherFieldName);
661             buffer.append("' value='");
662             buffer.append(otherValue);
663             buffer.append("' size='");
664             buffer.append(otherFieldSize);
665             buffer.append("' ");
666             buffer.append("\" +disa+ \" onfocus='check_choice(document.");
667             buffer.append(modelForm.getName());
668             buffer.append(".");
669             buffer.append(fieldName);
670             buffer.append(")'/>\");");
671             buffer.append("\nif(disa && document.styleSheets)");
672             buffer.append(" document.");
673             buffer.append(modelForm.getName());
674             buffer.append(".");
675             buffer.append(otherFieldName);
676             buffer.append(".style.visibility = 'hidden';");
677             buffer.append("\n//--></script>");
678         }
679         this.makeHyperlinkString(buffer, dropDownField.getSubHyperlink(), context);
680
681         this.appendTooltip(buffer, context, modelFormField);
682
683         this.appendWhitespace(buffer);
684     }
685
686     /* (non-Javadoc)
687      * @see org.ofbiz.widget.form.FormStringRenderer#renderCheckField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.CheckField)
688      */

689     public void renderCheckField(StringBuffer JavaDoc buffer, Map JavaDoc context, CheckField checkField) {
690         // well, I don't know if this will be very useful... but here it is
691

692         ModelFormField modelFormField = checkField.getModelFormField();
693         // never used: ModelForm modelForm = modelFormField.getModelForm();
694
String JavaDoc currentValue = modelFormField.getEntry(context);
695         
696         buffer.append("<span");
697         
698         String JavaDoc className = modelFormField.getWidgetStyle();
699         if (UtilValidate.isNotEmpty(className)) {
700             buffer.append(" class=\"");
701             buffer.append(className);
702             buffer.append('"');
703         }
704         buffer.append(">");
705
706         buffer.append("<input type=\"");
707         buffer.append("checkbox");
708         buffer.append('"');
709
710         // if current value should be selected in the list, select it
711
if ("Y".equals(currentValue) || "T".equals(currentValue)) {
712             buffer.append(" checked=\"checked\"");
713         }
714         buffer.append(" name=\"");
715         buffer.append(modelFormField.getParameterName(context));
716         buffer.append('"');
717         buffer.append(" value=\"Y\"/>");
718         // any description by it?
719

720         buffer.append("</span>");
721
722         this.appendTooltip(buffer, context, modelFormField);
723
724         this.appendWhitespace(buffer);
725     }
726
727     /* (non-Javadoc)
728      * @see org.ofbiz.widget.form.FormStringRenderer#renderRadioField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.RadioField)
729      */

730     public void renderRadioField(StringBuffer JavaDoc buffer, Map JavaDoc context, RadioField radioField) {
731         ModelFormField modelFormField = radioField.getModelFormField();
732         ModelForm modelForm = modelFormField.getModelForm();
733         List JavaDoc allOptionValues = radioField.getAllOptionValues(context, modelForm.getDelegator());
734         String JavaDoc currentValue = modelFormField.getEntry(context);
735         String JavaDoc event = modelFormField.getEvent();
736         String JavaDoc action = modelFormField.getAction();
737
738         // list out all options according to the option list
739
Iterator JavaDoc optionValueIter = allOptionValues.iterator();
740         while (optionValueIter.hasNext()) {
741             ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next();
742             String JavaDoc className = modelFormField.getWidgetStyle();
743             buffer.append("<div");
744             if (UtilValidate.isNotEmpty(className)) {
745                 buffer.append(" class=\"");
746                 buffer.append(className);
747                 buffer.append('"');
748             }
749             buffer.append(">");
750
751             buffer.append("<input type=\"");
752             buffer.append("radio");
753             buffer.append('"');
754
755             // if current value should be selected in the list, select it
756
String JavaDoc noCurrentSelectedKey = radioField.getNoCurrentSelectedKey(context);
757             if (UtilValidate.isNotEmpty(currentValue) && currentValue.equals(optionValue.getKey())) {
758                 buffer.append(" checked=\"checked\"");
759             } else if (UtilValidate.isEmpty(currentValue) && noCurrentSelectedKey != null && noCurrentSelectedKey.equals(optionValue.getKey())) {
760                 buffer.append(" checked=\"checked\"");
761             }
762             buffer.append(" name=\"");
763             buffer.append(modelFormField.getParameterName(context));
764             buffer.append('"');
765             buffer.append(" value=\"");
766             buffer.append(optionValue.getKey());
767             buffer.append("\"");
768
769             if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
770                 buffer.append(" ");
771                 buffer.append(event);
772                 buffer.append("=\"");
773                 buffer.append(action);
774                 buffer.append('"');
775             }
776             
777             buffer.append("/>");
778
779             buffer.append(optionValue.getDescription());
780             buffer.append("</div>");
781         }
782
783         this.appendTooltip(buffer, context, modelFormField);
784
785         this.appendWhitespace(buffer);
786     }
787
788     /* (non-Javadoc)
789      * @see org.ofbiz.widget.form.FormStringRenderer#renderSubmitField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.SubmitField)
790      */

791     public void renderSubmitField(StringBuffer JavaDoc buffer, Map JavaDoc context, SubmitField submitField) {
792         ModelFormField modelFormField = submitField.getModelFormField();
793         ModelForm modelForm = modelFormField.getModelForm();
794         String JavaDoc singleClickAction = " onClick=\"javascript:submitFormDisableButton(this)\" ";
795
796         if ("text-link".equals(submitField.getButtonType())) {
797             buffer.append("<a");
798
799             String JavaDoc className = modelFormField.getWidgetStyle();
800             if (UtilValidate.isNotEmpty(className)) {
801                 buffer.append(" class=\"");
802                 buffer.append(className);
803                 buffer.append('"');
804             }
805
806             buffer.append(" HREF=\"javascript:document.");
807             buffer.append(modelForm.getCurrentFormName(context));
808             buffer.append(".submit()\">");
809
810             buffer.append(modelFormField.getTitle(context));
811
812             buffer.append("</a>");
813         } else if ("image".equals(submitField.getButtonType())) {
814             buffer.append("<input type=\"image\"");
815
816             String JavaDoc className = modelFormField.getWidgetStyle();
817             if (UtilValidate.isNotEmpty(className)) {
818                 buffer.append(" class=\"");
819                 buffer.append(className);
820                 buffer.append('"');
821             }
822
823             buffer.append(" name=\"");
824             buffer.append(modelFormField.getParameterName(context));
825             buffer.append('"');
826
827             String JavaDoc title = modelFormField.getTitle(context);
828             if (UtilValidate.isNotEmpty(title)) {
829                 buffer.append(" alt=\"");
830                 buffer.append(title);
831                 buffer.append('"');
832             }
833
834             buffer.append(" SRC=\"");
835             this.appendContentUrl(buffer, submitField.getImageLocation());
836             buffer.append('"');
837
838             buffer.append(singleClickAction);
839             
840             buffer.append("/>");
841         } else {
842             // default to "button"
843

844             buffer.append("<input type=\"submit\"");
845
846             String JavaDoc className = modelFormField.getWidgetStyle();
847             if (UtilValidate.isNotEmpty(className)) {
848                 buffer.append(" class=\"");
849                 buffer.append(className);
850                 buffer.append('"');
851             }
852
853             buffer.append(" name=\"");
854             buffer.append(modelFormField.getParameterName(context));
855             buffer.append('"');
856
857             String JavaDoc title = modelFormField.getTitle(context);
858             if (UtilValidate.isNotEmpty(title)) {
859                 buffer.append(" value=\"");
860                 buffer.append(title);
861                 buffer.append('"');
862             }
863
864             // add single click JS onclick
865
buffer.append(singleClickAction);
866             
867             buffer.append("/>");
868         }
869
870         this.appendTooltip(buffer, context, modelFormField);
871
872         this.appendWhitespace(buffer);
873     }
874
875     /* (non-Javadoc)
876      * @see org.ofbiz.widget.form.FormStringRenderer#renderResetField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.ResetField)
877      */

878     public void renderResetField(StringBuffer JavaDoc buffer, Map JavaDoc context, ResetField resetField) {
879         ModelFormField modelFormField = resetField.getModelFormField();
880
881         buffer.append("<input type=\"reset\"");
882
883         String JavaDoc className = modelFormField.getWidgetStyle();
884         if (UtilValidate.isNotEmpty(className)) {
885             buffer.append(" class=\"");
886             buffer.append(className);
887             buffer.append('"');
888         }
889
890         buffer.append(" name=\"");
891         buffer.append(modelFormField.getParameterName(context));
892         buffer.append('"');
893
894         String JavaDoc title = modelFormField.getTitle(context);
895         if (UtilValidate.isNotEmpty(title)) {
896             buffer.append(" value=\"");
897             buffer.append(title);
898             buffer.append('"');
899         }
900
901         buffer.append("/>");
902
903         this.appendTooltip(buffer, context, modelFormField);
904
905         this.appendWhitespace(buffer);
906     }
907
908     /* (non-Javadoc)
909      * @see org.ofbiz.widget.form.FormStringRenderer#renderHiddenField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.HiddenField)
910      */

911     public void renderHiddenField(StringBuffer JavaDoc buffer, Map JavaDoc context, HiddenField hiddenField) {
912         ModelFormField modelFormField = hiddenField.getModelFormField();
913         String JavaDoc value = hiddenField.getValue(context);
914         this.renderHiddenField(buffer, context, modelFormField, value);
915     }
916
917     public void renderHiddenField(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField, String JavaDoc value) {
918         buffer.append("<input type=\"hidden\"");
919
920         buffer.append(" name=\"");
921         buffer.append(modelFormField.getParameterName(context));
922         buffer.append('"');
923
924         if (UtilValidate.isNotEmpty(value)) {
925             buffer.append(" value=\"");
926             buffer.append(value);
927             buffer.append('"');
928         }
929
930         buffer.append("/>");
931
932         this.appendWhitespace(buffer);
933     }
934
935     /* (non-Javadoc)
936      * @see org.ofbiz.widget.form.FormStringRenderer#renderIgnoredField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.IgnoredField)
937      */

938     public void renderIgnoredField(StringBuffer JavaDoc buffer, Map JavaDoc context, IgnoredField ignoredField) {
939         // do nothing, it's an ignored field; could add a comment or something if we wanted to
940
}
941
942     /* (non-Javadoc)
943      * @see org.ofbiz.widget.form.FormStringRenderer#renderFieldTitle(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField)
944      */

945     public void renderFieldTitle(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField) {
946         String JavaDoc tempTitleText = modelFormField.getTitle(context);
947         String JavaDoc titleText = UtilHttp.encodeAmpersands(tempTitleText);
948         
949         if (UtilValidate.isNotEmpty(titleText)) {
950             buffer.append("<span");
951             if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
952                 buffer.append(" class=\"");
953                 buffer.append(modelFormField.getTitleStyle());
954                 buffer.append("\"");
955             }
956             buffer.append(">");
957             renderHyperlinkTitle(buffer, context, modelFormField, titleText);
958             buffer.append("</span>");
959
960             this.appendWhitespace(buffer);
961         }
962     }
963
964     /* (non-Javadoc)
965      * @see org.ofbiz.widget.form.FormStringRenderer#renderFieldTitle(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField)
966      */

967     public void renderSingleFormFieldTitle(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField) {
968         boolean requiredField = modelFormField.getRequiredField();
969         if (requiredField) {
970             buffer.append("<span");
971             
972             String JavaDoc requiredStyle = modelFormField.getRequiredFieldStyle();
973             if (UtilValidate.isEmpty(requiredStyle)) {
974                 requiredStyle = modelFormField.getTitleStyle();
975             }
976             
977             if (UtilValidate.isNotEmpty(requiredStyle)) {
978                 buffer.append(" class=\"");
979                 buffer.append(requiredStyle);
980                 buffer.append("\"");
981             }
982             buffer.append(">");
983             renderHyperlinkTitle(buffer, context, modelFormField, modelFormField.getTitle(context));
984             buffer.append("</span>");
985
986             this.appendWhitespace(buffer);
987         } else {
988             renderFieldTitle(buffer, context, modelFormField);
989         }
990     }
991
992     /* (non-Javadoc)
993      * @see org.ofbiz.widget.form.FormStringRenderer#renderFormOpen(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
994      */

995     public void renderFormOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
996         buffer.append("<form method=\"post\" ");
997         String JavaDoc targ = modelForm.getTarget(context);
998         String JavaDoc targetType = modelForm.getTargetType();
999         // The 'action' attribute is mandatory in a form definition,
1000
// even if it is empty.
1001
buffer.append(" action=\"");
1002        if (targ != null && targ.length() > 0) {
1003            //this.appendOfbizUrl(buffer, "/" + targ);
1004
WidgetWorker.buildHyperlinkUrl(buffer, targ, targetType, request, response, context);
1005        }
1006        buffer.append("\" ");
1007
1008        String JavaDoc formType = modelForm.getType();
1009        if (formType.equals("upload") ) {
1010            buffer.append(" enctype=\"multipart/form-data\"");
1011        }
1012
1013        String JavaDoc targetWindow = modelForm.getTargetWindow(context);
1014        if (UtilValidate.isNotEmpty(targetWindow)) {
1015            buffer.append(" target=\"");
1016            buffer.append(targetWindow);
1017            buffer.append("\"");
1018        }
1019
1020        buffer.append(" name=\"");
1021        buffer.append(modelForm.getCurrentFormName(context));
1022        buffer.append("\" style=\"margin: 0;\">");
1023
1024        this.appendWhitespace(buffer);
1025    }
1026
1027    /* (non-Javadoc)
1028     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1029     */

1030    public void renderFormClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1031        buffer.append("</form>");
1032
1033        this.appendWhitespace(buffer);
1034    }
1035
1036    /* (non-Javadoc)
1037     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1038     */

1039    public void renderMultiFormClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1040        String JavaDoc rowCount = modelForm.getPassedRowCount(context);
1041        if (UtilValidate.isEmpty(rowCount)) {
1042            int rCount = modelForm.getRowCount();
1043            rowCount = Integer.toString(rCount);
1044        }
1045        if (UtilValidate.isNotEmpty(rowCount)) {
1046            buffer.append("<input type=\"hidden\" name=\"_rowCount\" value=\"" + rowCount + "\"/>");
1047        }
1048        boolean useRowSubmit = modelForm.getUseRowSubmit();
1049        if (useRowSubmit) {
1050            buffer.append("<input type=\"hidden\" name=\"_useRowSubmit\" value=\"Y\"/>");
1051        }
1052        
1053        ModelFormField submitField = modelForm.getMultiSubmitField();
1054        if (submitField != null) {
1055
1056            // Threw this in that as a hack to keep the submit button from expanding the first field
1057
// Needs a more rugged solution
1058
// WARNING: this method (renderMultiFormClose) must be called after the
1059
// table that contains the list has been closed (to avoid validation errors) so
1060
// we cannot call here the methods renderFormatItemRowCell*: for this reason
1061
// they are now commented.
1062

1063            // this.renderFormatItemRowCellOpen(buffer, context, modelForm, submitField);
1064
// this.renderFormatItemRowCellClose(buffer, context, modelForm, submitField);
1065

1066            // this.renderFormatItemRowCellOpen(buffer, context, modelForm, submitField);
1067

1068            submitField.renderFieldString(buffer, context, this);
1069
1070            // this.renderFormatItemRowCellClose(buffer, context, modelForm, submitField);
1071

1072        }
1073        buffer.append("</form>");
1074
1075        this.appendWhitespace(buffer);
1076    }
1077
1078    public void renderFormatListWrapperOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1079
1080         if(UtilValidate.isNotEmpty(modelForm.getDefaultTableStyle())) {
1081             buffer.append("<table");
1082             buffer.append(" class=\"");
1083             buffer.append(modelForm.getDefaultTableStyle());
1084             buffer.append("\"");
1085             buffer.append(">");
1086         } else {
1087             buffer.append("<table border=\"1\" cellpadding=\"2\" cellspacing=\"0\" class=\"calendarTable\">");
1088             // DEJ 20050101 removed the width=\"100%\", doesn't look very good with CSS float: left based side "columns"
1089
}
1090
1091        this.appendWhitespace(buffer);
1092    }
1093
1094    public void renderFormatListWrapperClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1095        buffer.append("</table>");
1096
1097        this.appendWhitespace(buffer);
1098        String JavaDoc queryString = null;
1099        if (UtilValidate.isNotEmpty((String JavaDoc)context.get("queryString"))) {
1100            queryString = (String JavaDoc)context.get("queryString");
1101        } else {
1102            Map JavaDoc inputFields = (Map JavaDoc)context.get("requestParameters");
1103            // strip out any multi form fields if the form is of type multi
1104
if (modelForm.getType().equals("multi")) {
1105                inputFields = UtilHttp.removeMultiFormParameters(inputFields);
1106            }
1107            queryString = UtilHttp.urlEncodeArgs(inputFields);
1108        }
1109        context.put("_QBESTRING_", queryString);
1110        this.renderNextPrev(buffer, context, modelForm);
1111    }
1112
1113    /* (non-Javadoc)
1114     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatHeaderRowOpen(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1115     */

1116    public void renderFormatHeaderRowOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1117        buffer.append("<tr");
1118        String JavaDoc headerStyle = modelForm.getHeaderRowStyle();
1119        if (UtilValidate.isNotEmpty(headerStyle)) {
1120            buffer.append(" class=\"");
1121            buffer.append(headerStyle);
1122            buffer.append("\"");
1123        }
1124        buffer.append(">");
1125        this.appendWhitespace(buffer);
1126    }
1127
1128    /* (non-Javadoc)
1129     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatHeaderRowClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1130     */

1131    public void renderFormatHeaderRowClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1132        buffer.append("</tr>");
1133
1134        this.appendWhitespace(buffer);
1135    }
1136
1137    /* (non-Javadoc)
1138     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatHeaderRowCellOpen(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm, org.ofbiz.widget.form.ModelFormField)
1139     */

1140    public void renderFormatHeaderRowCellOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm, ModelFormField modelFormField) {
1141        buffer.append("<td");
1142        String JavaDoc areaStyle = modelFormField.getTitleAreaStyle();
1143        if (UtilValidate.isNotEmpty(areaStyle)) {
1144            buffer.append(" class=\"");
1145            buffer.append(areaStyle);
1146            buffer.append("\"");
1147        }
1148        buffer.append(">");
1149        this.appendWhitespace(buffer);
1150    }
1151
1152    /* (non-Javadoc)
1153     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatHeaderRowCellClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm, org.ofbiz.widget.form.ModelFormField)
1154     */

1155    public void renderFormatHeaderRowCellClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm, ModelFormField modelFormField) {
1156        buffer.append("</td>");
1157        this.appendWhitespace(buffer);
1158    }
1159
1160    public void renderFormatHeaderRowFormCellOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1161        buffer.append("<td align=\"center\"");
1162        String JavaDoc areaStyle = modelForm.getFormTitleAreaStyle();
1163        if (UtilValidate.isNotEmpty(areaStyle)) {
1164            buffer.append(" class=\"");
1165            buffer.append(areaStyle);
1166            buffer.append("\"");
1167        }
1168        buffer.append(">");
1169        this.appendWhitespace(buffer);
1170    }
1171
1172    /* (non-Javadoc)
1173     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatHeaderRowFormCellClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1174     */

1175    public void renderFormatHeaderRowFormCellClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1176        buffer.append("</td>");
1177        this.appendWhitespace(buffer);
1178    }
1179
1180    /* (non-Javadoc)
1181     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatHeaderRowFormCellTitleSeparator(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm, boolean)
1182     */

1183    public void renderFormatHeaderRowFormCellTitleSeparator(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) {
1184        buffer.append("<span");
1185        
1186        String JavaDoc titleStyle = modelFormField.getTitleStyle();
1187        if (UtilValidate.isNotEmpty(titleStyle)) {
1188            buffer.append(" class=\"");
1189            buffer.append(titleStyle);
1190            buffer.append("\"");
1191        }
1192        buffer.append(">");
1193        if (isLast) {
1194            buffer.append(" - ");
1195        } else {
1196            buffer.append(" - ");
1197        }
1198        buffer.append("</span>");
1199    }
1200
1201    /* (non-Javadoc)
1202     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatItemRowOpen(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1203     */

1204    public void renderFormatItemRowOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1205        Integer JavaDoc itemIndex = (Integer JavaDoc)context.get("itemIndex");
1206        
1207        buffer.append("<tr");
1208        if (itemIndex!=null) {
1209            
1210            if (itemIndex.intValue()%2==0) {
1211               String JavaDoc evenRowStyle = modelForm.getEvenRowStyle();
1212               if (UtilValidate.isNotEmpty(evenRowStyle)) {
1213                   buffer.append(" class=\"");
1214                   buffer.append(evenRowStyle);
1215                   buffer.append("\"");
1216                }
1217            } else {
1218                  String JavaDoc oddRowStyle = modelForm.getOddRowStyle();
1219                  if (UtilValidate.isNotEmpty(oddRowStyle)) {
1220                      buffer.append(" class=\"");
1221                      buffer.append(oddRowStyle);
1222                      buffer.append("\"");
1223                  }
1224            }
1225        }
1226        buffer.append(">");
1227        this.appendWhitespace(buffer);
1228    }
1229
1230    /* (non-Javadoc)
1231     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatItemRowClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1232     */

1233    public void renderFormatItemRowClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1234        buffer.append("</tr>");
1235
1236        this.appendWhitespace(buffer);
1237    }
1238
1239    /* (non-Javadoc)
1240     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatItemRowCellOpen(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm, org.ofbiz.widget.form.ModelFormField)
1241     */

1242    public void renderFormatItemRowCellOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm, ModelFormField modelFormField) {
1243        buffer.append("<td");
1244        String JavaDoc areaStyle = modelFormField.getWidgetAreaStyle();
1245        if (UtilValidate.isNotEmpty(areaStyle)) {
1246            buffer.append(" class=\"");
1247            buffer.append(areaStyle);
1248            buffer.append("\"");
1249        }
1250        buffer.append(">");
1251        this.appendWhitespace(buffer);
1252    }
1253
1254    /* (non-Javadoc)
1255     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatItemRowCellClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm, org.ofbiz.widget.form.ModelFormField)
1256     */

1257    public void renderFormatItemRowCellClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm, ModelFormField modelFormField) {
1258        buffer.append("</td>");
1259        this.appendWhitespace(buffer);
1260    }
1261
1262    /* (non-Javadoc)
1263     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatItemRowFormCellOpen(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1264     */

1265    public void renderFormatItemRowFormCellOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1266        buffer.append("<td align=\"center\"");
1267        String JavaDoc areaStyle = modelForm.getFormWidgetAreaStyle();
1268        if (UtilValidate.isNotEmpty(areaStyle)) {
1269            buffer.append(" class=\"");
1270            buffer.append(areaStyle);
1271            buffer.append("\"");
1272        }
1273        buffer.append(">");
1274        this.appendWhitespace(buffer);
1275    }
1276
1277    /* (non-Javadoc)
1278     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatItemRowFormCellClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1279     */

1280    public void renderFormatItemRowFormCellClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1281        buffer.append("</td>");
1282        this.appendWhitespace(buffer);
1283    }
1284
1285    public void renderFormatSingleWrapperOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1286        buffer.append("<table border=\"0\" cellpadding=\"2\" cellspacing=\"0\">");
1287
1288        this.appendWhitespace(buffer);
1289    }
1290
1291    public void renderFormatSingleWrapperClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1292        buffer.append("</table>");
1293
1294        this.appendWhitespace(buffer);
1295    }
1296
1297    /* (non-Javadoc)
1298     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatFieldRowOpen(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1299     */

1300    public void renderFormatFieldRowOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1301        buffer.append("<tr>");
1302
1303        this.appendWhitespace(buffer);
1304    }
1305
1306    /* (non-Javadoc)
1307     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatFieldRowClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
1308     */

1309    public void renderFormatFieldRowClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1310        buffer.append("</tr>");
1311
1312        this.appendWhitespace(buffer);
1313    }
1314
1315    /* (non-Javadoc)
1316     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatFieldRowTitleCellOpen(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField)
1317     */

1318    public void renderFormatFieldRowTitleCellOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField) {
1319        buffer.append("<td width=\"20%\" align=\"right\"");
1320        String JavaDoc areaStyle = modelFormField.getTitleAreaStyle();
1321        if (UtilValidate.isNotEmpty(areaStyle)) {
1322            buffer.append(" class=\"");
1323            buffer.append(areaStyle);
1324            buffer.append("\"");
1325        }
1326        buffer.append(">");
1327        this.appendWhitespace(buffer);
1328    }
1329
1330    /* (non-Javadoc)
1331     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatFieldRowTitleCellClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField)
1332     */

1333    public void renderFormatFieldRowTitleCellClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField) {
1334        buffer.append("</td>");
1335        this.appendWhitespace(buffer);
1336    }
1337
1338    /* (non-Javadoc)
1339     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatFieldRowSpacerCell(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField)
1340     */

1341    public void renderFormatFieldRowSpacerCell(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField) {
1342        buffer.append("<td>&nbsp;</td>");
1343
1344        this.appendWhitespace(buffer);
1345    }
1346
1347    /* (non-Javadoc)
1348     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatFieldRowWidgetCellOpen(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField, int)
1349     */

1350    public void renderFormatFieldRowWidgetCellOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField, int positions, int positionSpan, Integer JavaDoc nextPositionInRow) {
1351        buffer.append("<td width=\"");
1352        if (nextPositionInRow != null || modelFormField.getPosition() > 1) {
1353            buffer.append("30");
1354        } else {
1355            buffer.append("80");
1356        }
1357        buffer.append("%\" align=\"left\"");
1358        if (positionSpan > 0) {
1359            buffer.append(" colspan=\"");
1360            // do a span of 1 for this column, plus 3 columns for each spanned
1361
//position or each blank position that this will be filling in
1362
buffer.append(1 + (positionSpan * 3));
1363            buffer.append("\"");
1364        }
1365        String JavaDoc areaStyle = modelFormField.getWidgetAreaStyle();
1366        if (UtilValidate.isNotEmpty(areaStyle)) {
1367            buffer.append(" class=\"");
1368            buffer.append(areaStyle);
1369            buffer.append("\"");
1370        }
1371        buffer.append(">");
1372
1373        this.appendWhitespace(buffer);
1374    }
1375
1376    /* (non-Javadoc)
1377     * @see org.ofbiz.widget.form.FormStringRenderer#renderFormatFieldRowWidgetCellClose(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField, int)
1378     */

1379    public void renderFormatFieldRowWidgetCellClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField, int positions, int positionSpan, Integer JavaDoc nextPositionInRow) {
1380        buffer.append("</td>");
1381        this.appendWhitespace(buffer);
1382    }
1383
1384    public void renderFormatEmptySpace(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1385        buffer.append("&nbsp;");
1386    }
1387
1388    /* (non-Javadoc)
1389     * @see org.ofbiz.widget.form.FormStringRenderer#renderTextFindField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.TextFindField)
1390     */

1391    public void renderTextFindField(StringBuffer JavaDoc buffer, Map JavaDoc context, TextFindField textFindField) {
1392
1393        ModelFormField modelFormField = textFindField.getModelFormField();
1394        Locale JavaDoc locale = (Locale JavaDoc)context.get("locale");
1395        String JavaDoc opEquals = UtilProperties.getMessage("conditional", "equals", locale);
1396        String JavaDoc opBeginsWith = UtilProperties.getMessage("conditional", "begins_with", locale);
1397        String JavaDoc opContains = UtilProperties.getMessage("conditional", "contains", locale);
1398        String JavaDoc opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
1399        String JavaDoc ignoreCase = UtilProperties.getMessage("conditional", "ignore_case", locale);
1400
1401        String JavaDoc defaultOption = textFindField.getDefaultOption();
1402        boolean ignCase = textFindField.getIgnoreCase();
1403
1404        buffer.append(" <select name=\"");
1405        buffer.append(modelFormField.getParameterName(context));
1406        buffer.append("_op\" class=\"selectBox\">");
1407        buffer.append("<option value=\"equals\"" + ("equals".equals(defaultOption)? " selected": "") + ">" + opEquals + "</option>");
1408        buffer.append("<option value=\"like\"" + ("like".equals(defaultOption)? " selected": "") + ">" + opBeginsWith + "</option>");
1409        buffer.append("<option value=\"contains\"" + ("contains".equals(defaultOption)? " selected": "") + ">" + opContains + "</option>");
1410        buffer.append("<option value=\"empty\"" + ("empty".equals(defaultOption)? " selected": "") + ">" + opIsEmpty + "</option>");
1411        buffer.append("</select>");
1412        
1413        buffer.append("<input type=\"text\"");
1414
1415        String JavaDoc className = modelFormField.getWidgetStyle();
1416        if (UtilValidate.isNotEmpty(className)) {
1417            buffer.append(" class=\"");
1418            buffer.append(className);
1419            buffer.append('"');
1420        }
1421
1422        // add a style of red if this is a date/time field and redWhen is true
1423
if (modelFormField.shouldBeRed(context)) {
1424            buffer.append(" style=\"color: red;\"");
1425        }
1426
1427        buffer.append(" name=\"");
1428        buffer.append(modelFormField.getParameterName(context));
1429        buffer.append('"');
1430
1431        String JavaDoc value = modelFormField.getEntry(context, textFindField.getDefaultValue(context));
1432        if (UtilValidate.isNotEmpty(value)) {
1433            buffer.append(" value=\"");
1434            buffer.append(value);
1435            buffer.append('"');
1436        }
1437
1438        buffer.append(" size=\"");
1439        buffer.append(textFindField.getSize());
1440        buffer.append('"');
1441
1442        Integer JavaDoc maxlength = textFindField.getMaxlength();
1443        if (maxlength != null) {
1444            buffer.append(" maxlength=\"");
1445            buffer.append(maxlength.intValue());
1446            buffer.append('"');
1447        }
1448
1449        buffer.append("/>");
1450
1451        buffer.append(" <span");
1452        if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
1453            buffer.append(" class=\"");
1454            buffer.append(modelFormField.getTitleStyle());
1455            buffer.append('"');
1456        }
1457        buffer.append('>');
1458
1459        buffer.append(" <input type=\"checkbox\" name=\"");
1460        buffer.append(modelFormField.getParameterName(context));
1461        buffer.append("_ic\" value=\"Y\"" + (ignCase ? " checked=\"checked\"" : "") + "/>");
1462        buffer.append(ignoreCase);
1463        
1464        buffer.append("</span>");
1465
1466        this.appendTooltip(buffer, context, modelFormField);
1467
1468        this.appendWhitespace(buffer);
1469    }
1470
1471    /* (non-Javadoc)
1472     * @see org.ofbiz.widget.form.FormStringRenderer#renderRangeFindField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.RangeFindField)
1473     */

1474    public void renderRangeFindField(StringBuffer JavaDoc buffer, Map JavaDoc context, RangeFindField rangeFindField) {
1475
1476        ModelFormField modelFormField = rangeFindField.getModelFormField();
1477        Locale JavaDoc locale = (Locale JavaDoc)context.get("locale");
1478        String JavaDoc opEquals = UtilProperties.getMessage("conditional", "equals", locale);
1479        String JavaDoc opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale);
1480        String JavaDoc opGreaterThanEquals = UtilProperties.getMessage("conditional", "greater_than_equals", locale);
1481        String JavaDoc opLessThan = UtilProperties.getMessage("conditional", "less_than", locale);
1482        String JavaDoc opLessThanEquals = UtilProperties.getMessage("conditional", "less_than_equals", locale);
1483        //String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
1484

1485        buffer.append("<input type=\"text\"");
1486
1487        String JavaDoc className = modelFormField.getWidgetStyle();
1488        if (UtilValidate.isNotEmpty(className)) {
1489            buffer.append(" class=\"");
1490            buffer.append(className);
1491            buffer.append('"');
1492        }
1493
1494        // add a style of red if this is a date/time field and redWhen is true
1495
if (modelFormField.shouldBeRed(context)) {
1496            buffer.append(" style=\"color: red;\"");
1497        }
1498
1499        buffer.append(" name=\"");
1500        buffer.append(modelFormField.getParameterName(context));
1501        buffer.append("_fld0_value\"");
1502
1503        String JavaDoc value = modelFormField.getEntry(context, rangeFindField.getDefaultValue(context));
1504        if (UtilValidate.isNotEmpty(value)) {
1505            buffer.append(" value=\"");
1506            buffer.append(value);
1507            buffer.append('"');
1508        }
1509
1510        buffer.append(" size=\"");
1511        buffer.append(rangeFindField.getSize());
1512        buffer.append('"');
1513
1514        Integer JavaDoc maxlength = rangeFindField.getMaxlength();
1515        if (maxlength != null) {
1516            buffer.append(" maxlength=\"");
1517            buffer.append(maxlength.intValue());
1518            buffer.append('"');
1519        }
1520
1521        buffer.append("/>");
1522
1523        buffer.append(" <span");
1524        if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
1525            buffer.append(" class=\"");
1526            buffer.append(modelFormField.getTitleStyle());
1527            buffer.append('"');
1528        }
1529        buffer.append('>');
1530
1531        buffer.append(" <select name=\"");
1532        buffer.append(modelFormField.getParameterName(context));
1533        buffer.append("_fld0_op\" class=\"selectBox\">");
1534        buffer.append("<option value=\"equals\" selected>" + opEquals + "</option>");
1535        buffer.append("<option value=\"greaterThan\">" + opGreaterThan + "</option>");
1536        buffer.append("<option value=\"greaterThanEqualTo\">" + opGreaterThanEquals + "</option>");
1537        buffer.append("</select>");
1538
1539        buffer.append("</span>");
1540
1541        buffer.append(" <br/> ");
1542
1543        buffer.append("<input type=\"text\"");
1544
1545        className = modelFormField.getWidgetStyle();
1546        if (UtilValidate.isNotEmpty(className)) {
1547            buffer.append(" class=\"");
1548            buffer.append(className);
1549            buffer.append('"');
1550        }
1551
1552        // add a style of red if this is a date/time field and redWhen is true
1553
if (modelFormField.shouldBeRed(context)) {
1554            buffer.append(" style=\"color: red;\"");
1555        }
1556
1557        buffer.append(" name=\"");
1558        buffer.append(modelFormField.getParameterName(context));
1559        buffer.append("_fld1_value\"");
1560
1561        value = modelFormField.getEntry(context);
1562        if (UtilValidate.isNotEmpty(value)) {
1563            buffer.append(" value=\"");
1564            buffer.append(value);
1565            buffer.append('"');
1566        }
1567
1568        buffer.append(" size=\"");
1569        buffer.append(rangeFindField.getSize());
1570        buffer.append('"');
1571
1572        if (maxlength != null) {
1573            buffer.append(" maxlength=\"");
1574            buffer.append(maxlength.intValue());
1575            buffer.append('"');
1576        }
1577
1578        buffer.append("/>");
1579
1580        buffer.append(" <span");
1581        if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
1582            buffer.append(" class=\"");
1583            buffer.append(modelFormField.getTitleStyle());
1584            buffer.append('"');
1585        }
1586        buffer.append('>');
1587
1588        buffer.append(" <select name=\"");
1589        buffer.append(modelFormField.getParameterName(context));
1590        buffer.append("_fld1_op\" class=\"selectBox\">");
1591        buffer.append("<option value=\"lessThan\">" + opLessThan + "</option>");
1592        buffer.append("<option value=\"lessThanEqualTo\">" + opLessThanEquals + "</option>");
1593        buffer.append("</select>");
1594
1595        buffer.append("</span>");
1596
1597        this.appendTooltip(buffer, context, modelFormField);
1598
1599        this.appendWhitespace(buffer);
1600    }
1601
1602    /* (non-Javadoc)
1603     * @see org.ofbiz.widget.form.FormStringRenderer#renderDateFindField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.DateFindField)
1604     */

1605    public void renderDateFindField(StringBuffer JavaDoc buffer, Map JavaDoc context, DateFindField dateFindField) {
1606        ModelFormField modelFormField = dateFindField.getModelFormField();
1607
1608        Locale JavaDoc locale = (Locale JavaDoc)context.get("locale");
1609        String JavaDoc opEquals = UtilProperties.getMessage("conditional", "equals", locale);
1610        String JavaDoc opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale);
1611        String JavaDoc opSameDay = UtilProperties.getMessage("conditional", "same_day", locale);
1612        String JavaDoc opGreaterThanFromDayStart = UtilProperties.getMessage("conditional",
1613                                                "greater_than_from_day_start", locale);
1614        String JavaDoc opLessThan = UtilProperties.getMessage("conditional", "less_than", locale);
1615        String JavaDoc opUpToDay = UtilProperties.getMessage("conditional", "up_to_day", locale);
1616        String JavaDoc opUpThruDay = UtilProperties.getMessage("conditional", "up_thru_day", locale);
1617        String JavaDoc opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale);
1618
1619        buffer.append("<input type=\"text\"");
1620
1621        String JavaDoc className = modelFormField.getWidgetStyle();
1622        if (UtilValidate.isNotEmpty(className)) {
1623            buffer.append(" class=\"");
1624            buffer.append(className);
1625            buffer.append('"');
1626        }
1627
1628        // add a style of red if this is a date/time field and redWhen is true
1629
if (modelFormField.shouldBeRed(context)) {
1630            buffer.append(" style=\"color: red;\"");
1631        }
1632
1633        buffer.append(" name=\"");
1634        buffer.append(modelFormField.getParameterName(context));
1635        buffer.append("_fld0_value\"");
1636
1637        String JavaDoc value = modelFormField.getEntry(context, dateFindField.getDefaultValue(context));
1638        if (UtilValidate.isNotEmpty(value)) {
1639            buffer.append(" value=\"");
1640            buffer.append(value);
1641            buffer.append('"');
1642        }
1643
1644        // the default values for a timestamp
1645
int size = 25;
1646        int maxlength = 30;
1647
1648        buffer.append(" size=\"");
1649        buffer.append(size);
1650        buffer.append('"');
1651
1652        buffer.append(" maxlength=\"");
1653        buffer.append(maxlength);
1654        buffer.append('"');
1655
1656        buffer.append("/>");
1657
1658        // add calendar pop-up button and seed data
1659
buffer.append("<a HREF=\"javascript:call_cal(document.");
1660        buffer.append(modelFormField.getModelForm().getCurrentFormName(context));
1661        buffer.append('.');
1662        buffer.append(modelFormField.getParameterName(context));
1663        buffer.append("_fld0_value,'");
1664        buffer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context))));
1665        buffer.append("');\">");
1666        buffer.append("<img SRC=\"");
1667        this.appendContentUrl(buffer, "/content/images/cal.gif");
1668        buffer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"Calendar\"/></a>");
1669
1670        buffer.append(" <span");
1671        if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
1672            buffer.append(" class=\"");
1673            buffer.append(modelFormField.getTitleStyle());
1674            buffer.append('"');
1675        }
1676        buffer.append('>');
1677
1678        buffer.append(" <select name=\"");
1679        buffer.append(modelFormField.getParameterName(context));
1680        buffer.append("_fld0_op\" class=\"selectBox\">");
1681        buffer.append("<option value=\"equals\" selected>" + opEquals + "</option>");
1682        buffer.append("<option value=\"sameDay\">" + opSameDay + "</option>");
1683        buffer.append("<option value=\"greaterThanFromDayStart\">" + opGreaterThanFromDayStart + "</option>");
1684        buffer.append("<option value=\"greaterThan\">" + opGreaterThan + "</option>");
1685        buffer.append("</select>");
1686
1687        buffer.append(" </span>");
1688
1689        buffer.append(" <br/> ");
1690
1691        buffer.append("<input type=\"text\"");
1692        className = modelFormField.getWidgetStyle();
1693        if (UtilValidate.isNotEmpty(className)) {
1694            buffer.append(" class=\"");
1695            buffer.append(className);
1696            buffer.append('"');
1697        }
1698
1699        // add a style of red if this is a date/time field and redWhen is true
1700
if (modelFormField.shouldBeRed(context)) {
1701            buffer.append(" style=\"color: red;\"");
1702        }
1703
1704        buffer.append(" name=\"");
1705        buffer.append(modelFormField.getParameterName(context));
1706        buffer.append("_fld1_value\"");
1707
1708        value = modelFormField.getEntry(context);
1709        if (UtilValidate.isNotEmpty(value)) {
1710            buffer.append(" value=\"");
1711            buffer.append(value);
1712            buffer.append('"');
1713        }
1714
1715        buffer.append(" size=\"");
1716        buffer.append(size);
1717        buffer.append('"');
1718
1719        buffer.append(" maxlength=\"");
1720        buffer.append(maxlength);
1721        buffer.append('"');
1722
1723        buffer.append("/>");
1724
1725        // add calendar pop-up button and seed data
1726
buffer.append("<a HREF=\"javascript:call_cal(document.");
1727        buffer.append(modelFormField.getModelForm().getCurrentFormName(context));
1728        buffer.append('.');
1729        buffer.append(modelFormField.getParameterName(context));
1730        buffer.append("_fld1_value,'");
1731        buffer.append(UtilHttp.encodeBlanks(modelFormField.getEntry(context, dateFindField.getDefaultDateTimeString(context))));
1732        buffer.append("');\">");
1733        buffer.append("<img SRC=\"");
1734        this.appendContentUrl(buffer, "/content/images/cal.gif");
1735        buffer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"Calendar\"/></a>");
1736
1737        buffer.append(" <span");
1738        if (UtilValidate.isNotEmpty(modelFormField.getTitleStyle())) {
1739            buffer.append(" class=\"");
1740            buffer.append(modelFormField.getTitleStyle());
1741            buffer.append('"');
1742        }
1743        buffer.append('>');
1744
1745        buffer.append(" <select name=\"");
1746        buffer.append(modelFormField.getParameterName(context));
1747        buffer.append("_fld1_op\" class=\"selectBox\">");
1748        buffer.append("<option value=\"lessThan\">" + opLessThan + "</option>");
1749        buffer.append("<option value=\"upToDay\">" + opUpToDay + "</option>");
1750        buffer.append("<option value=\"upThruDay\">" + opUpThruDay + "</option>");
1751        buffer.append("<option value=\"empty\">" + opIsEmpty + "</option>");
1752        buffer.append("</select>");
1753
1754        buffer.append("</span>");
1755
1756        this.appendTooltip(buffer, context, modelFormField);
1757
1758        this.appendWhitespace(buffer);
1759    }
1760
1761    /* (non-Javadoc)
1762     * @see org.ofbiz.widget.form.FormStringRenderer#renderLookupField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.LookupField)
1763     */

1764    public void renderLookupField(StringBuffer JavaDoc buffer, Map JavaDoc context, LookupField lookupField) {
1765        ModelFormField modelFormField = lookupField.getModelFormField();
1766
1767        buffer.append("<input type=\"text\"");
1768
1769        String JavaDoc className = modelFormField.getWidgetStyle();
1770        if (UtilValidate.isNotEmpty(className)) {
1771            buffer.append(" class=\"");
1772            buffer.append(className);
1773            buffer.append('"');
1774        }
1775
1776        // add a style of red if this is a date/time field and redWhen is true
1777
if (modelFormField.shouldBeRed(context)) {
1778            buffer.append(" style=\"color: red;\"");
1779        }
1780
1781        buffer.append(" name=\"");
1782        buffer.append(modelFormField.getParameterName(context));
1783        buffer.append('"');
1784
1785        String JavaDoc value = modelFormField.getEntry(context, lookupField.getDefaultValue(context));
1786        if (UtilValidate.isNotEmpty(value)) {
1787            buffer.append(" value=\"");
1788            buffer.append(value);
1789            buffer.append('"');
1790        }
1791
1792        buffer.append(" size=\"");
1793        buffer.append(lookupField.getSize());
1794        buffer.append('"');
1795
1796        Integer JavaDoc maxlength = lookupField.getMaxlength();
1797        if (maxlength != null) {
1798            buffer.append(" maxlength=\"");
1799            buffer.append(maxlength.intValue());
1800            buffer.append('"');
1801        }
1802
1803        buffer.append("/>");
1804
1805        String JavaDoc descriptionFieldName = lookupField.getDescriptionFieldName();
1806        // add lookup pop-up button
1807
if (UtilValidate.isNotEmpty(descriptionFieldName)) {
1808            buffer.append("<a HREF=\"javascript:call_fieldlookup3(document.");
1809            buffer.append(modelFormField.getModelForm().getCurrentFormName(context));
1810            buffer.append('.');
1811            buffer.append(modelFormField.getParameterName(context));
1812            buffer.append(",'");
1813            buffer.append(descriptionFieldName);
1814            buffer.append(",'");
1815        } else {
1816            buffer.append("<a HREF=\"javascript:call_fieldlookup2(document.");
1817            buffer.append(modelFormField.getModelForm().getCurrentFormName(context));
1818            buffer.append('.');
1819            buffer.append(modelFormField.getParameterName(context));
1820            buffer.append(",'");
1821        }
1822        buffer.append(lookupField.getFormName(context));
1823        buffer.append("'");
1824        List JavaDoc targetParameterList = lookupField.getTargetParameterList();
1825        if (targetParameterList.size() > 0) {
1826            Iterator JavaDoc targetParameterIter = targetParameterList.iterator();
1827            while (targetParameterIter.hasNext()) {
1828                String JavaDoc targetParameter = (String JavaDoc) targetParameterIter.next();
1829                // named like: document.${formName}.${targetParameter}.value
1830
buffer.append(", document.");
1831                buffer.append(modelFormField.getModelForm().getCurrentFormName(context));
1832                buffer.append(".");
1833                buffer.append(targetParameter);
1834                buffer.append(".value");
1835            }
1836        }
1837        buffer.append(");\">");
1838        buffer.append("<img SRC=\"");
1839        this.appendContentUrl(buffer, "/content/images/fieldlookup.gif");
1840        buffer.append("\" width=\"16\" height=\"16\" border=\"0\" alt=\"Lookup\"/></a>");
1841
1842        this.makeHyperlinkString(buffer, lookupField.getSubHyperlink(), context);
1843        this.appendTooltip(buffer, context, modelFormField);
1844
1845        this.appendWhitespace(buffer);
1846    }
1847
1848    public void renderNextPrev(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm modelForm) {
1849        String JavaDoc targetService = modelForm.getPaginateTarget(context);
1850        if (targetService == null) {
1851            targetService = "${targetService}";
1852        }
1853        if (UtilValidate.isEmpty(targetService)) {
1854            Debug.logWarning("TargetService is empty.", module);
1855            return;
1856        }
1857
1858        // get the parametrized pagination index and size fields
1859
String JavaDoc viewIndexParam = modelForm.getPaginateIndexField(context);
1860        String JavaDoc viewSizeParam = modelForm.getPaginateSizeField(context);
1861
1862        int viewIndex = -1;
1863        try {
1864            Object JavaDoc value = context.get(viewIndexParam);
1865            if (value instanceof Integer JavaDoc)
1866                viewIndex = ((Integer JavaDoc) value).intValue();
1867            else if (value instanceof String JavaDoc)
1868                viewIndex = Integer.parseInt((String JavaDoc) value);
1869        } catch (Exception JavaDoc e) {
1870            viewIndex = 0;
1871        }
1872
1873        int viewSize = -1;
1874        try {
1875            Object JavaDoc value = context.get(viewSizeParam);
1876            if (value instanceof Integer JavaDoc)
1877                viewSize = ((Integer JavaDoc) value).intValue();
1878            else if (value instanceof String JavaDoc)
1879                viewSize = Integer.parseInt((String JavaDoc) value);
1880        } catch (Exception JavaDoc e) {
1881            viewSize = modelForm.getViewSize();
1882        }
1883
1884        int listSize = -1;
1885        try {
1886            listSize = modelForm.getListSize();
1887        } catch (Exception JavaDoc e) {
1888            listSize = -1;
1889        }
1890
1891/*
1892        int highIndex = -1;
1893        try {
1894            highIndex = modelForm.getHighIndex();
1895        } catch (Exception e) {
1896            highIndex = 0;
1897        }
1898
1899        int lowIndex = -1;
1900        try {
1901            lowIndex = modelForm.getLowIndex();
1902        } catch (Exception e) {
1903            lowIndex = 0;
1904        }
1905*/

1906        
1907        int lowIndex = viewIndex * viewSize;
1908        int highIndex = (viewIndex + 1) * viewSize;
1909        int actualPageSize = modelForm.getActualPageSize();
1910        // if this is all there seems to be (if listSize < 0, then size is unknown)
1911
if (actualPageSize >= listSize && listSize >= 0) {
1912            return;
1913        }
1914
1915        // for legacy support, the viewSizeParam is VIEW_SIZE and viewIndexParam is VIEW_INDEX when the fields are "viewSize" and "viewIndex"
1916
if (viewIndexParam.equals("viewIndex")) viewIndexParam = "VIEW_INDEX";
1917        if (viewSizeParam.equals("viewSize")) viewSizeParam = "VIEW_SIZE";
1918
1919        String JavaDoc str = (String JavaDoc) context.get("_QBESTRING_");
1920        ServletContext JavaDoc ctx = (ServletContext JavaDoc) request.getAttribute("servletContext");
1921        RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
1922
1923        // strip legacy viewIndex/viewSize params from the query string
1924
String JavaDoc queryString = UtilHttp.stripViewParamsFromQueryString(str);
1925
1926        // strip parametrized index/size params from the query string
1927
HashSet JavaDoc paramNames = new HashSet JavaDoc();
1928        paramNames.add(viewIndexParam);
1929        paramNames.add(viewSizeParam);
1930        queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames);
1931
1932        String JavaDoc anchor = "";
1933        String JavaDoc paginateAnchor = modelForm.getPaginateTargetAnchor();
1934        if (paginateAnchor != null) anchor = "#" + paginateAnchor;
1935
1936        buffer.append("<table border=\"0\" cellpadding=\"2\">\n");
1937        buffer.append(" <tr>\n");
1938        buffer.append(" <td align=\"right\">\n");
1939        buffer.append(" <b>\n");
1940        if (viewIndex > 0) {
1941            buffer.append(" <a HREF=\"");
1942            String JavaDoc linkText = targetService;
1943            if (linkText.indexOf("?") < 0) linkText += "?";
1944            else linkText += "&amp;";
1945            if (queryString != null && !queryString.equals("null"))
1946                linkText += queryString + "&amp;";
1947            linkText += viewSizeParam + "=" + viewSize + "&amp;" + viewIndexParam + "=" + (viewIndex - 1) + anchor + "\"";
1948
1949            // make the link
1950
String JavaDoc tmp = rh.makeLink(request, response, linkText);
1951            buffer.append(tmp);
1952            buffer.append(" class=\"").append(modelForm.getPaginatePreviousStyle()).append("\">").append(modelForm.getPaginatePreviousLabel(context)).append("</a>\n");
1953
1954        }
1955        if (listSize > 0) {
1956            buffer.append(" <span class=\"tabletext\">" + (lowIndex + 1) + " - " + (lowIndex + actualPageSize ) + " of " + listSize + "</span> \n");
1957        }
1958        if (highIndex < listSize) {
1959            buffer.append(" <a HREF=\"");
1960            String JavaDoc linkText = "" + targetService;
1961            if (linkText.indexOf("?") < 0) linkText += "?";
1962            else linkText += "&amp;";
1963            linkText += queryString + "&amp;" + viewSizeParam + "=" + viewSize + "&amp;" + viewIndexParam + "=" + (viewIndex + 1) + anchor + "\"";
1964
1965            // make the link
1966
buffer.append(rh.makeLink(request, response, linkText));
1967            buffer.append(" class=\"").append(modelForm.getPaginatePreviousStyle()).append("\">").append(modelForm.getPaginateNextLabel(context)).append("</a>\n");
1968
1969        }
1970        buffer.append(" </b>\n");
1971        buffer.append(" </td>\n");
1972        buffer.append(" </tr>\n");
1973        buffer.append("</table>\n");
1974
1975        this.appendWhitespace(buffer);
1976    }
1977
1978    /* (non-Javadoc)
1979     * @see org.ofbiz.widget.form.FormStringRenderer#renderFileField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.FileField)
1980     */

1981    public void renderFileField(StringBuffer JavaDoc buffer, Map JavaDoc context, FileField textField) {
1982        ModelFormField modelFormField = textField.getModelFormField();
1983
1984        buffer.append("<input type=\"file\"");
1985
1986        String JavaDoc className = modelFormField.getWidgetStyle();
1987        if (UtilValidate.isNotEmpty(className)) {
1988            buffer.append(" class=\"");
1989            buffer.append(className);
1990            buffer.append('"');
1991        }
1992
1993        // add a style of red if this is a date/time field and redWhen is true
1994
if (modelFormField.shouldBeRed(context)) {
1995            buffer.append(" style=\"color: red;\"");
1996        }
1997
1998        buffer.append(" name=\"");
1999        buffer.append(modelFormField.getParameterName(context));
2000        buffer.append('"');
2001
2002        String JavaDoc value = modelFormField.getEntry(context, textField.getDefaultValue(context));
2003        if (UtilValidate.isNotEmpty(value)) {
2004            buffer.append(" value=\"");
2005            buffer.append(value);
2006            buffer.append('"');
2007        }
2008
2009        buffer.append(" size=\"");
2010        buffer.append(textField.getSize());
2011        buffer.append('"');
2012
2013        Integer JavaDoc maxlength = textField.getMaxlength();
2014        if (maxlength != null) {
2015            buffer.append(" maxlength=\"");
2016            buffer.append(maxlength.intValue());
2017            buffer.append('"');
2018        }
2019
2020        buffer.append("/>");
2021
2022        this.makeHyperlinkString(buffer, textField.getSubHyperlink(), context);
2023
2024        this.appendTooltip(buffer, context, modelFormField);
2025
2026        this.appendWhitespace(buffer);
2027    }
2028
2029    /* (non-Javadoc)
2030     * @see org.ofbiz.widget.form.FormStringRenderer#renderPasswordField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.PasswordField)
2031     */

2032    public void renderPasswordField(StringBuffer JavaDoc buffer, Map JavaDoc context, PasswordField passwordField) {
2033        ModelFormField modelFormField = passwordField.getModelFormField();
2034
2035        buffer.append("<input type=\"password\"");
2036
2037        String JavaDoc className = modelFormField.getWidgetStyle();
2038        if (UtilValidate.isNotEmpty(className)) {
2039            buffer.append(" class=\"");
2040            buffer.append(className);
2041            buffer.append('"');
2042        }
2043
2044        // add a style of red if this is a date/time field and redWhen is true
2045
if (modelFormField.shouldBeRed(context)) {
2046            buffer.append(" style=\"color: red;\"");
2047        }
2048
2049        buffer.append(" name=\"");
2050        buffer.append(modelFormField.getParameterName(context));
2051        buffer.append('"');
2052
2053        String JavaDoc value = modelFormField.getEntry(context, passwordField.getDefaultValue(context));
2054        if (UtilValidate.isNotEmpty(value)) {
2055            buffer.append(" value=\"");
2056            buffer.append(value);
2057            buffer.append('"');
2058        }
2059
2060        buffer.append(" size=\"");
2061        buffer.append(passwordField.getSize());
2062        buffer.append('"');
2063
2064        Integer JavaDoc maxlength = passwordField.getMaxlength();
2065        if (maxlength != null) {
2066            buffer.append(" maxlength=\"");
2067            buffer.append(maxlength.intValue());
2068            buffer.append('"');
2069        }
2070
2071        String JavaDoc idName = modelFormField.getIdName();
2072        if (UtilValidate.isNotEmpty(idName)) {
2073            buffer.append(" id=\"");
2074            buffer.append(idName);
2075            buffer.append('"');
2076        }
2077
2078        buffer.append("/>");
2079
2080        this.addAstericks(buffer, context, modelFormField);
2081
2082        this.makeHyperlinkString(buffer, passwordField.getSubHyperlink(), context);
2083
2084        this.appendTooltip(buffer, context, modelFormField);
2085
2086        this.appendWhitespace(buffer);
2087    }
2088
2089    /* (non-Javadoc)
2090     * @see org.ofbiz.widget.form.FormStringRenderer#renderImageField(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelFormField.ImageField)
2091     */

2092    public void renderImageField(StringBuffer JavaDoc buffer, Map JavaDoc context, ImageField imageField) {
2093        ModelFormField modelFormField = imageField.getModelFormField();
2094
2095        buffer.append("<img ");
2096
2097
2098        String JavaDoc value = modelFormField.getEntry(context, imageField.getValue(context));
2099        if (UtilValidate.isNotEmpty(value)) {
2100            buffer.append(" SRC=\"");
2101            ContentUrlTag.appendContentPrefix(request, buffer);
2102            buffer.append(value);
2103            buffer.append('"');
2104        }
2105
2106        buffer.append(" border=\"");
2107        buffer.append(imageField.getBorder());
2108        buffer.append('"');
2109
2110        Integer JavaDoc width = imageField.getWidth();
2111        if (width != null) {
2112            buffer.append(" width=\"");
2113            buffer.append(width.intValue());
2114            buffer.append('"');
2115        }
2116
2117        Integer JavaDoc height = imageField.getHeight();
2118        if (height != null) {
2119            buffer.append(" height=\"");
2120            buffer.append(height.intValue());
2121            buffer.append('"');
2122        }
2123
2124        String JavaDoc event = modelFormField.getEvent();
2125        String JavaDoc action = modelFormField.getAction();
2126        if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
2127            buffer.append(" ");
2128            buffer.append(event);
2129            buffer.append("=\"");
2130            buffer.append(action);
2131            buffer.append('"');
2132        }
2133
2134        buffer.append("/>");
2135
2136        this.makeHyperlinkString(buffer, imageField.getSubHyperlink(), context);
2137
2138        this.appendTooltip(buffer, context, modelFormField);
2139
2140        this.appendWhitespace(buffer);
2141    }
2142    
2143    public void renderFieldGroupOpen(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm.FieldGroup fieldGroup) {
2144        String JavaDoc style = fieldGroup.getStyle();
2145        if (UtilValidate.isNotEmpty(style)) {
2146            buffer.append("<div");
2147            buffer.append(" class=\"");
2148            buffer.append(style);
2149            buffer.append("\">");
2150        }
2151    }
2152     
2153    public void renderFieldGroupClose(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm.FieldGroup fieldGroup) {
2154        String JavaDoc style = fieldGroup.getStyle();
2155        if (UtilValidate.isNotEmpty(style)) {
2156            buffer.append("</div>");
2157        }
2158    }
2159     
2160    public void renderBanner(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelForm.Banner banner) {
2161        buffer.append("<table width=\"100%\"><tr>");
2162        String JavaDoc style = banner.getStyle(context);
2163        String JavaDoc leftStyle = banner.getLeftTextStyle(context);
2164        if (UtilValidate.isEmpty(leftStyle)) leftStyle = style;
2165        String JavaDoc rightStyle = banner.getRightTextStyle(context);
2166        if (UtilValidate.isEmpty(rightStyle)) rightStyle = style;
2167        
2168        String JavaDoc leftText = banner.getLeftText(context);
2169        if (UtilValidate.isNotEmpty(leftText)) {
2170            buffer.append("<td align=\"left\">");
2171            if (UtilValidate.isNotEmpty(leftStyle)) {
2172               buffer.append("<div");
2173               buffer.append(" class=\"");
2174               buffer.append(leftStyle);
2175               buffer.append("\"");
2176               buffer.append(">" );
2177            }
2178            buffer.append(leftText);
2179            if (UtilValidate.isNotEmpty(leftStyle)) {
2180                buffer.append("</div>");
2181            }
2182            buffer.append("</td>");
2183        }
2184        
2185        String JavaDoc text = banner.getText(context);
2186        if (UtilValidate.isNotEmpty(text)) {
2187            buffer.append("<td align=\"center\">");
2188            if (UtilValidate.isNotEmpty(style)) {
2189               buffer.append("<div");
2190               buffer.append(" class=\"");
2191               buffer.append(style);
2192               buffer.append("\"");
2193               buffer.append(">" );
2194            }
2195            buffer.append(text);
2196            if (UtilValidate.isNotEmpty(style)) {
2197                buffer.append("</div>");
2198            }
2199            buffer.append("</td>");
2200        }
2201        
2202        String JavaDoc rightText = banner.getRightText(context);
2203        if (UtilValidate.isNotEmpty(rightText)) {
2204            buffer.append("<td align=\"right\">");
2205            if (UtilValidate.isNotEmpty(rightStyle)) {
2206               buffer.append("<div");
2207               buffer.append(" class=\"");
2208               buffer.append(rightStyle);
2209               buffer.append("\"");
2210               buffer.append(">" );
2211            }
2212            buffer.append(rightText);
2213            if (UtilValidate.isNotEmpty(rightStyle)) {
2214                buffer.append("</div>");
2215            }
2216            buffer.append("</td>");
2217        }
2218        buffer.append("</tr></table>");
2219    }
2220    
2221    /**
2222     * Renders a link for the column header fields when there is a header-link="" specified in the <field > tag, using
2223     * style from header-link-style="". Also renders a selectAll checkbox in multi forms.
2224     * @param buffer
2225     * @param context
2226     * @param modelFormField
2227     * @param titleText
2228     */

2229    public void renderHyperlinkTitle(StringBuffer JavaDoc buffer, Map JavaDoc context, ModelFormField modelFormField, String JavaDoc titleText) {
2230        if (UtilValidate.isNotEmpty(modelFormField.getHeaderLink())) {
2231            StringBuffer JavaDoc targetBuffer = new StringBuffer JavaDoc();
2232            FlexibleStringExpander target = new FlexibleStringExpander(modelFormField.getHeaderLink());
2233            String JavaDoc fullTarget = target.expandString(context);
2234            targetBuffer.append(fullTarget);
2235            makeHyperlinkString(buffer, modelFormField.getHeaderLinkStyle(), HyperlinkField.DEFAULT_TARGET_TYPE, targetBuffer.toString(), titleText, null);
2236        } else if (modelFormField.isRowSubmit()) {
2237            if (UtilValidate.isNotEmpty(titleText)) buffer.append(titleText).append("<br>");
2238            buffer.append("<input type=\"checkbox\" name=\"selectAll\" value=\"Y\" onclick=\"javascript:toggleAll(this, '");
2239            buffer.append(modelFormField.getModelForm().getName());
2240            buffer.append("');\"/>");
2241        } else {
2242             buffer.append(titleText);
2243        }
2244    }
2245}
2246
Popular Tags