1 24 package org.ofbiz.widget.html; 25 26 import java.util.Iterator ; 27 import java.util.List ; 28 import java.util.Locale ; 29 import java.util.Map ; 30 import java.util.HashSet ; 31 import java.util.Calendar ; 32 import java.sql.Timestamp ; 33 34 import javax.servlet.ServletContext ; 35 import javax.servlet.http.HttpServletRequest ; 36 import javax.servlet.http.HttpServletResponse ; 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 79 public class HtmlFormRenderer implements FormStringRenderer { 80 81 public static final String module = HtmlFormRenderer.class.getName(); 82 83 HttpServletRequest request; 84 HttpServletResponse response; 85 protected String lastFieldGroupId = ""; 86 87 protected HtmlFormRenderer() {} 88 89 public HtmlFormRenderer(HttpServletRequest request, HttpServletResponse response) { 90 this.request = request; 91 this.response = response; 92 } 93 94 public void appendWhitespace(StringBuffer buffer) { 95 buffer.append("\r\n"); 97 } 99 100 public void appendOfbizUrl(StringBuffer buffer, String location) { 101 ServletContext ctx = (ServletContext ) this.request.getAttribute("servletContext"); 102 RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); 103 buffer.append(rh.makeLink(this.request, this.response, location)); 105 } 106 107 public void appendContentUrl(StringBuffer buffer, String location) { 108 ContentUrlTag.appendContentPrefix(this.request, buffer); 109 buffer.append(location); 110 } 111 112 public void appendTooltip(StringBuffer buffer, Map context, ModelFormField modelFormField) { 113 String tooltip = modelFormField.getTooltip(context); 115 if (UtilValidate.isNotEmpty(tooltip)) { 116 buffer.append("<span"); 117 String 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 buffer, Map context, ModelFormField modelFormField) { 130 131 boolean requiredField = modelFormField.getRequiredField(); 132 if (requiredField) { 133 String requiredStyle = modelFormField.getRequiredFieldStyle(); 134 135 if (UtilValidate.isEmpty(requiredStyle)) { 136 buffer.append("*"); 137 } 138 } 139 return; 140 } 141 142 145 public void renderDisplayField(StringBuffer buffer, Map 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 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 177 public void renderHyperlinkField(StringBuffer buffer, Map 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 buffer, ModelFormField.SubHyperlink subHyperlink, Map 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 buffer, String linkStyle, String targetType, String target, String description, String targetWindow) { 207 Map context = null; 208 WidgetWorker.makeHyperlinkString(buffer, linkStyle, targetType, target, description, this.request, this.response, context, targetWindow); 209 } 210 211 214 public void renderTextField(StringBuffer buffer, Map context, TextField textField) { 215 ModelFormField modelFormField = textField.getModelFormField(); 216 217 buffer.append("<input type=\"text\""); 218 219 String className = modelFormField.getWidgetStyle(); 220 if (UtilValidate.isNotEmpty(className)) { 221 buffer.append(" class=\""); 222 buffer.append(className); 223 buffer.append('"'); 224 } 225 226 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 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 maxlength = textField.getMaxlength(); 247 if (maxlength != null) { 248 buffer.append(" maxlength=\""); 249 buffer.append(maxlength.intValue()); 250 buffer.append('"'); 251 } 252 253 String idName = modelFormField.getIdName(); 254 if (UtilValidate.isNotEmpty(idName)) { 255 buffer.append(" id=\""); 256 buffer.append(idName); 257 buffer.append('"'); 258 } 259 260 String event = modelFormField.getEvent(); 261 String 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 284 public void renderTextareaField(StringBuffer buffer, Map context, TextareaField textareaField) { 285 ModelFormField modelFormField = textareaField.getModelFormField(); 286 287 buffer.append("<textarea"); 288 289 String 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 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 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 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 358 public void renderDateTimeField(StringBuffer buffer, Map context, DateTimeField dateTimeField) { 359 ModelFormField modelFormField = dateTimeField.getModelFormField(); 360 String paramName = modelFormField.getParameterName(context); 361 String defaultDateTimeString = dateTimeField.getDefaultDateTimeString(context); 362 363 boolean shortDateInput = ("date".equals(dateTimeField.getType()) || "time-dropdown".equals(dateTimeField.getInputMethod()) ? true : false); 365 366 buffer.append("<input type=\"text\""); 367 368 String className = modelFormField.getWidgetStyle(); 369 if (UtilValidate.isNotEmpty(className)) { 370 buffer.append(" class=\""); 371 buffer.append(className); 372 buffer.append('"'); 373 } 374 375 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 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 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 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 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 ("time-dropdown".equals(dateTimeField.getInputMethod())) { 454 String classString = (className != null ? " class=\"" + className + "\" " : ""); 455 boolean isTwelveHour = "12".equals(dateTimeField.getClock()); 456 457 Calendar cal = null; 459 try { 460 Timestamp defaultTimestamp = Timestamp.valueOf(modelFormField.getEntry(context, defaultDateTimeString)); 461 cal = Calendar.getInstance(); 462 cal.setTime(defaultTimestamp); 463 } catch (IllegalArgumentException 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 buffer.append(" <select name=\"").append(UtilHttp.makeCompositeParam(paramName, "hour")).append("\""); 470 buffer.append(classString).append(">"); 471 472 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 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 (isTwelveHour) { 509 String amSelected = ((cal != null && cal.get(Calendar.AM_PM) == Calendar.AM) ? "selected" : ""); 510 String 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 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 532 public void renderDropDownField(StringBuffer buffer, Map context, DropDownField dropDownField) { 533 ModelFormField modelFormField = dropDownField.getModelFormField(); 534 ModelForm modelForm = modelFormField.getModelForm(); 535 536 String event = modelFormField.getEvent(); 537 String action = modelFormField.getAction(); 538 539 buffer.append("<select"); 540 541 String 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 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 otherFieldName = dropDownField.getParameterNameOther(context); 561 if (otherFieldSize > 0) { 562 buffer.append(" onchange=\"process_choice(this,document."); 565 buffer.append(modelForm.getName()); 566 buffer.append("."); 567 buffer.append(otherFieldName); 568 buffer.append(")\" "); 569 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 currentValue = modelFormField.getEntry(context); 585 List allOptionValues = dropDownField.getAllOptionValues(context, modelForm.getDelegator()); 586 587 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 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 buffer.append("<option value=\""); 604 buffer.append(currentValue); 605 buffer.append("\">---</option>"); 606 } 607 608 if (dropDownField.isAllowEmpty()) { 610 buffer.append("<option value=\"\"> </option>"); 611 } 612 613 Iterator optionValueIter = allOptionValues.iterator(); 615 while (optionValueIter.hasNext()) { 616 ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next(); 617 String noCurrentSelectedKey = dropDownField.getNoCurrentSelectedKey(context); 618 buffer.append("<option"); 619 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 if (otherFieldSize > 0) { 637 638 String fieldName = modelFormField.getParameterName(context); 639 Map dataMap = modelFormField.getMap(context); 640 if (dataMap == null) { 641 dataMap = context; 642 } 643 Object otherValueObj = dataMap.get(otherFieldName); 644 String 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 689 public void renderCheckField(StringBuffer buffer, Map context, CheckField checkField) { 690 692 ModelFormField modelFormField = checkField.getModelFormField(); 693 String currentValue = modelFormField.getEntry(context); 695 696 buffer.append("<span"); 697 698 String 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 ("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 720 buffer.append("</span>"); 721 722 this.appendTooltip(buffer, context, modelFormField); 723 724 this.appendWhitespace(buffer); 725 } 726 727 730 public void renderRadioField(StringBuffer buffer, Map context, RadioField radioField) { 731 ModelFormField modelFormField = radioField.getModelFormField(); 732 ModelForm modelForm = modelFormField.getModelForm(); 733 List allOptionValues = radioField.getAllOptionValues(context, modelForm.getDelegator()); 734 String currentValue = modelFormField.getEntry(context); 735 String event = modelFormField.getEvent(); 736 String action = modelFormField.getAction(); 737 738 Iterator optionValueIter = allOptionValues.iterator(); 740 while (optionValueIter.hasNext()) { 741 ModelFormField.OptionValue optionValue = (ModelFormField.OptionValue) optionValueIter.next(); 742 String 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 String 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 791 public void renderSubmitField(StringBuffer buffer, Map context, SubmitField submitField) { 792 ModelFormField modelFormField = submitField.getModelFormField(); 793 ModelForm modelForm = modelFormField.getModelForm(); 794 String singleClickAction = " onClick=\"javascript:submitFormDisableButton(this)\" "; 795 796 if ("text-link".equals(submitField.getButtonType())) { 797 buffer.append("<a"); 798 799 String 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 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 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 844 buffer.append("<input type=\"submit\""); 845 846 String 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 title = modelFormField.getTitle(context); 858 if (UtilValidate.isNotEmpty(title)) { 859 buffer.append(" value=\""); 860 buffer.append(title); 861 buffer.append('"'); 862 } 863 864 buffer.append(singleClickAction); 866 867 buffer.append("/>"); 868 } 869 870 this.appendTooltip(buffer, context, modelFormField); 871 872 this.appendWhitespace(buffer); 873 } 874 875 878 public void renderResetField(StringBuffer buffer, Map context, ResetField resetField) { 879 ModelFormField modelFormField = resetField.getModelFormField(); 880 881 buffer.append("<input type=\"reset\""); 882 883 String 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 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 911 public void renderHiddenField(StringBuffer buffer, Map context, HiddenField hiddenField) { 912 ModelFormField modelFormField = hiddenField.getModelFormField(); 913 String value = hiddenField.getValue(context); 914 this.renderHiddenField(buffer, context, modelFormField, value); 915 } 916 917 public void renderHiddenField(StringBuffer buffer, Map context, ModelFormField modelFormField, String 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 938 public void renderIgnoredField(StringBuffer buffer, Map context, IgnoredField ignoredField) { 939 } 941 942 945 public void renderFieldTitle(StringBuffer buffer, Map context, ModelFormField modelFormField) { 946 String tempTitleText = modelFormField.getTitle(context); 947 String 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 967 public void renderSingleFormFieldTitle(StringBuffer buffer, Map context, ModelFormField modelFormField) { 968 boolean requiredField = modelFormField.getRequiredField(); 969 if (requiredField) { 970 buffer.append("<span"); 971 972 String 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 995 public void renderFormOpen(StringBuffer buffer, Map context, ModelForm modelForm) { 996 buffer.append("<form method=\"post\" "); 997 String targ = modelForm.getTarget(context); 998 String targetType = modelForm.getTargetType(); 999 buffer.append(" action=\""); 1002 if (targ != null && targ.length() > 0) { 1003 WidgetWorker.buildHyperlinkUrl(buffer, targ, targetType, request, response, context); 1005 } 1006 buffer.append("\" "); 1007 1008 String formType = modelForm.getType(); 1009 if (formType.equals("upload") ) { 1010 buffer.append(" enctype=\"multipart/form-data\""); 1011 } 1012 1013 String 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 1030 public void renderFormClose(StringBuffer buffer, Map context, ModelForm modelForm) { 1031 buffer.append("</form>"); 1032 1033 this.appendWhitespace(buffer); 1034 } 1035 1036 1039 public void renderMultiFormClose(StringBuffer buffer, Map context, ModelForm modelForm) { 1040 String 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 1063 1066 1068 submitField.renderFieldString(buffer, context, this); 1069 1070 1072 } 1073 buffer.append("</form>"); 1074 1075 this.appendWhitespace(buffer); 1076 } 1077 1078 public void renderFormatListWrapperOpen(StringBuffer buffer, Map 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 } 1090 1091 this.appendWhitespace(buffer); 1092 } 1093 1094 public void renderFormatListWrapperClose(StringBuffer buffer, Map context, ModelForm modelForm) { 1095 buffer.append("</table>"); 1096 1097 this.appendWhitespace(buffer); 1098 String queryString = null; 1099 if (UtilValidate.isNotEmpty((String )context.get("queryString"))) { 1100 queryString = (String )context.get("queryString"); 1101 } else { 1102 Map inputFields = (Map )context.get("requestParameters"); 1103 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 1116 public void renderFormatHeaderRowOpen(StringBuffer buffer, Map context, ModelForm modelForm) { 1117 buffer.append("<tr"); 1118 String 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 1131 public void renderFormatHeaderRowClose(StringBuffer buffer, Map context, ModelForm modelForm) { 1132 buffer.append("</tr>"); 1133 1134 this.appendWhitespace(buffer); 1135 } 1136 1137 1140 public void renderFormatHeaderRowCellOpen(StringBuffer buffer, Map context, ModelForm modelForm, ModelFormField modelFormField) { 1141 buffer.append("<td"); 1142 String 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 1155 public void renderFormatHeaderRowCellClose(StringBuffer buffer, Map context, ModelForm modelForm, ModelFormField modelFormField) { 1156 buffer.append("</td>"); 1157 this.appendWhitespace(buffer); 1158 } 1159 1160 public void renderFormatHeaderRowFormCellOpen(StringBuffer buffer, Map context, ModelForm modelForm) { 1161 buffer.append("<td align=\"center\""); 1162 String 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 1175 public void renderFormatHeaderRowFormCellClose(StringBuffer buffer, Map context, ModelForm modelForm) { 1176 buffer.append("</td>"); 1177 this.appendWhitespace(buffer); 1178 } 1179 1180 1183 public void renderFormatHeaderRowFormCellTitleSeparator(StringBuffer buffer, Map context, ModelForm modelForm, ModelFormField modelFormField, boolean isLast) { 1184 buffer.append("<span"); 1185 1186 String 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 1204 public void renderFormatItemRowOpen(StringBuffer buffer, Map context, ModelForm modelForm) { 1205 Integer itemIndex = (Integer )context.get("itemIndex"); 1206 1207 buffer.append("<tr"); 1208 if (itemIndex!=null) { 1209 1210 if (itemIndex.intValue()%2==0) { 1211 String evenRowStyle = modelForm.getEvenRowStyle(); 1212 if (UtilValidate.isNotEmpty(evenRowStyle)) { 1213 buffer.append(" class=\""); 1214 buffer.append(evenRowStyle); 1215 buffer.append("\""); 1216 } 1217 } else { 1218 String 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 1233 public void renderFormatItemRowClose(StringBuffer buffer, Map context, ModelForm modelForm) { 1234 buffer.append("</tr>"); 1235 1236 this.appendWhitespace(buffer); 1237 } 1238 1239 1242 public void renderFormatItemRowCellOpen(StringBuffer buffer, Map context, ModelForm modelForm, ModelFormField modelFormField) { 1243 buffer.append("<td"); 1244 String 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 1257 public void renderFormatItemRowCellClose(StringBuffer buffer, Map context, ModelForm modelForm, ModelFormField modelFormField) { 1258 buffer.append("</td>"); 1259 this.appendWhitespace(buffer); 1260 } 1261 1262 1265 public void renderFormatItemRowFormCellOpen(StringBuffer buffer, Map context, ModelForm modelForm) { 1266 buffer.append("<td align=\"center\""); 1267 String 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 1280 public void renderFormatItemRowFormCellClose(StringBuffer buffer, Map context, ModelForm modelForm) { 1281 buffer.append("</td>"); 1282 this.appendWhitespace(buffer); 1283 } 1284 1285 public void renderFormatSingleWrapperOpen(StringBuffer buffer, Map 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 buffer, Map context, ModelForm modelForm) { 1292 buffer.append("</table>"); 1293 1294 this.appendWhitespace(buffer); 1295 } 1296 1297 1300 public void renderFormatFieldRowOpen(StringBuffer buffer, Map context, ModelForm modelForm) { 1301 buffer.append("<tr>"); 1302 1303 this.appendWhitespace(buffer); 1304 } 1305 1306 1309 public void renderFormatFieldRowClose(StringBuffer buffer, Map context, ModelForm modelForm) { 1310 buffer.append("</tr>"); 1311 1312 this.appendWhitespace(buffer); 1313 } 1314 1315 1318 public void renderFormatFieldRowTitleCellOpen(StringBuffer buffer, Map context, ModelFormField modelFormField) { 1319 buffer.append("<td width=\"20%\" align=\"right\""); 1320 String 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 1333 public void renderFormatFieldRowTitleCellClose(StringBuffer buffer, Map context, ModelFormField modelFormField) { 1334 buffer.append("</td>"); 1335 this.appendWhitespace(buffer); 1336 } 1337 1338 1341 public void renderFormatFieldRowSpacerCell(StringBuffer buffer, Map context, ModelFormField modelFormField) { 1342 buffer.append("<td> </td>"); 1343 1344 this.appendWhitespace(buffer); 1345 } 1346 1347 1350 public void renderFormatFieldRowWidgetCellOpen(StringBuffer buffer, Map context, ModelFormField modelFormField, int positions, int positionSpan, Integer 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 buffer.append(1 + (positionSpan * 3)); 1363 buffer.append("\""); 1364 } 1365 String 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 1379 public void renderFormatFieldRowWidgetCellClose(StringBuffer buffer, Map context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) { 1380 buffer.append("</td>"); 1381 this.appendWhitespace(buffer); 1382 } 1383 1384 public void renderFormatEmptySpace(StringBuffer buffer, Map context, ModelForm modelForm) { 1385 buffer.append(" "); 1386 } 1387 1388 1391 public void renderTextFindField(StringBuffer buffer, Map context, TextFindField textFindField) { 1392 1393 ModelFormField modelFormField = textFindField.getModelFormField(); 1394 Locale locale = (Locale )context.get("locale"); 1395 String opEquals = UtilProperties.getMessage("conditional", "equals", locale); 1396 String opBeginsWith = UtilProperties.getMessage("conditional", "begins_with", locale); 1397 String opContains = UtilProperties.getMessage("conditional", "contains", locale); 1398 String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale); 1399 String ignoreCase = UtilProperties.getMessage("conditional", "ignore_case", locale); 1400 1401 String 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 className = modelFormField.getWidgetStyle(); 1416 if (UtilValidate.isNotEmpty(className)) { 1417 buffer.append(" class=\""); 1418 buffer.append(className); 1419 buffer.append('"'); 1420 } 1421 1422 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 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 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 1474 public void renderRangeFindField(StringBuffer buffer, Map context, RangeFindField rangeFindField) { 1475 1476 ModelFormField modelFormField = rangeFindField.getModelFormField(); 1477 Locale locale = (Locale )context.get("locale"); 1478 String opEquals = UtilProperties.getMessage("conditional", "equals", locale); 1479 String opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale); 1480 String opGreaterThanEquals = UtilProperties.getMessage("conditional", "greater_than_equals", locale); 1481 String opLessThan = UtilProperties.getMessage("conditional", "less_than", locale); 1482 String opLessThanEquals = UtilProperties.getMessage("conditional", "less_than_equals", locale); 1483 1485 buffer.append("<input type=\"text\""); 1486 1487 String className = modelFormField.getWidgetStyle(); 1488 if (UtilValidate.isNotEmpty(className)) { 1489 buffer.append(" class=\""); 1490 buffer.append(className); 1491 buffer.append('"'); 1492 } 1493 1494 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 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 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 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 1605 public void renderDateFindField(StringBuffer buffer, Map context, DateFindField dateFindField) { 1606 ModelFormField modelFormField = dateFindField.getModelFormField(); 1607 1608 Locale locale = (Locale )context.get("locale"); 1609 String opEquals = UtilProperties.getMessage("conditional", "equals", locale); 1610 String opGreaterThan = UtilProperties.getMessage("conditional", "greater_than", locale); 1611 String opSameDay = UtilProperties.getMessage("conditional", "same_day", locale); 1612 String opGreaterThanFromDayStart = UtilProperties.getMessage("conditional", 1613 "greater_than_from_day_start", locale); 1614 String opLessThan = UtilProperties.getMessage("conditional", "less_than", locale); 1615 String opUpToDay = UtilProperties.getMessage("conditional", "up_to_day", locale); 1616 String opUpThruDay = UtilProperties.getMessage("conditional", "up_thru_day", locale); 1617 String opIsEmpty = UtilProperties.getMessage("conditional", "is_empty", locale); 1618 1619 buffer.append("<input type=\"text\""); 1620 1621 String className = modelFormField.getWidgetStyle(); 1622 if (UtilValidate.isNotEmpty(className)) { 1623 buffer.append(" class=\""); 1624 buffer.append(className); 1625 buffer.append('"'); 1626 } 1627 1628 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 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 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 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 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 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 1764 public void renderLookupField(StringBuffer buffer, Map context, LookupField lookupField) { 1765 ModelFormField modelFormField = lookupField.getModelFormField(); 1766 1767 buffer.append("<input type=\"text\""); 1768 1769 String className = modelFormField.getWidgetStyle(); 1770 if (UtilValidate.isNotEmpty(className)) { 1771 buffer.append(" class=\""); 1772 buffer.append(className); 1773 buffer.append('"'); 1774 } 1775 1776 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 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 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 descriptionFieldName = lookupField.getDescriptionFieldName(); 1806 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 targetParameterList = lookupField.getTargetParameterList(); 1825 if (targetParameterList.size() > 0) { 1826 Iterator targetParameterIter = targetParameterList.iterator(); 1827 while (targetParameterIter.hasNext()) { 1828 String targetParameter = (String ) targetParameterIter.next(); 1829 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 buffer, Map context, ModelForm modelForm) { 1849 String 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 String viewIndexParam = modelForm.getPaginateIndexField(context); 1860 String viewSizeParam = modelForm.getPaginateSizeField(context); 1861 1862 int viewIndex = -1; 1863 try { 1864 Object value = context.get(viewIndexParam); 1865 if (value instanceof Integer ) 1866 viewIndex = ((Integer ) value).intValue(); 1867 else if (value instanceof String ) 1868 viewIndex = Integer.parseInt((String ) value); 1869 } catch (Exception e) { 1870 viewIndex = 0; 1871 } 1872 1873 int viewSize = -1; 1874 try { 1875 Object value = context.get(viewSizeParam); 1876 if (value instanceof Integer ) 1877 viewSize = ((Integer ) value).intValue(); 1878 else if (value instanceof String ) 1879 viewSize = Integer.parseInt((String ) value); 1880 } catch (Exception e) { 1881 viewSize = modelForm.getViewSize(); 1882 } 1883 1884 int listSize = -1; 1885 try { 1886 listSize = modelForm.getListSize(); 1887 } catch (Exception e) { 1888 listSize = -1; 1889 } 1890 1891 1906 1907 int lowIndex = viewIndex * viewSize; 1908 int highIndex = (viewIndex + 1) * viewSize; 1909 int actualPageSize = modelForm.getActualPageSize(); 1910 if (actualPageSize >= listSize && listSize >= 0) { 1912 return; 1913 } 1914 1915 if (viewIndexParam.equals("viewIndex")) viewIndexParam = "VIEW_INDEX"; 1917 if (viewSizeParam.equals("viewSize")) viewSizeParam = "VIEW_SIZE"; 1918 1919 String str = (String ) context.get("_QBESTRING_"); 1920 ServletContext ctx = (ServletContext ) request.getAttribute("servletContext"); 1921 RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_"); 1922 1923 String queryString = UtilHttp.stripViewParamsFromQueryString(str); 1925 1926 HashSet paramNames = new HashSet (); 1928 paramNames.add(viewIndexParam); 1929 paramNames.add(viewSizeParam); 1930 queryString = UtilHttp.stripNamedParamsFromQueryString(queryString, paramNames); 1931 1932 String anchor = ""; 1933 String 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 linkText = targetService; 1943 if (linkText.indexOf("?") < 0) linkText += "?"; 1944 else linkText += "&"; 1945 if (queryString != null && !queryString.equals("null")) 1946 linkText += queryString + "&"; 1947 linkText += viewSizeParam + "=" + viewSize + "&" + viewIndexParam + "=" + (viewIndex - 1) + anchor + "\""; 1948 1949 String 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 linkText = "" + targetService; 1961 if (linkText.indexOf("?") < 0) linkText += "?"; 1962 else linkText += "&"; 1963 linkText += queryString + "&" + viewSizeParam + "=" + viewSize + "&" + viewIndexParam + "=" + (viewIndex + 1) + anchor + "\""; 1964 1965 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 1981 public void renderFileField(StringBuffer buffer, Map context, FileField textField) { 1982 ModelFormField modelFormField = textField.getModelFormField(); 1983 1984 buffer.append("<input type=\"file\""); 1985 1986 String className = modelFormField.getWidgetStyle(); 1987 if (UtilValidate.isNotEmpty(className)) { 1988 buffer.append(" class=\""); 1989 buffer.append(className); 1990 buffer.append('"'); 1991 } 1992 1993 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 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 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 2032 public void renderPasswordField(StringBuffer buffer, Map context, PasswordField passwordField) { 2033 ModelFormField modelFormField = passwordField.getModelFormField(); 2034 2035 buffer.append("<input type=\"password\""); 2036 2037 String className = modelFormField.getWidgetStyle(); 2038 if (UtilValidate.isNotEmpty(className)) { 2039 buffer.append(" class=\""); 2040 buffer.append(className); 2041 buffer.append('"'); 2042 } 2043 2044 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 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 maxlength = passwordField.getMaxlength(); 2065 if (maxlength != null) { 2066 buffer.append(" maxlength=\""); 2067 buffer.append(maxlength.intValue()); 2068 buffer.append('"'); 2069 } 2070 2071 String 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 2092 public void renderImageField(StringBuffer buffer, Map context, ImageField imageField) { 2093 ModelFormField modelFormField = imageField.getModelFormField(); 2094 2095 buffer.append("<img "); 2096 2097 2098 String 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 width = imageField.getWidth(); 2111 if (width != null) { 2112 buffer.append(" width=\""); 2113 buffer.append(width.intValue()); 2114 buffer.append('"'); 2115 } 2116 2117 Integer height = imageField.getHeight(); 2118 if (height != null) { 2119 buffer.append(" height=\""); 2120 buffer.append(height.intValue()); 2121 buffer.append('"'); 2122 } 2123 2124 String event = modelFormField.getEvent(); 2125 String 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 buffer, Map context, ModelForm.FieldGroup fieldGroup) { 2144 String 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 buffer, Map context, ModelForm.FieldGroup fieldGroup) { 2154 String style = fieldGroup.getStyle(); 2155 if (UtilValidate.isNotEmpty(style)) { 2156 buffer.append("</div>"); 2157 } 2158 } 2159 2160 public void renderBanner(StringBuffer buffer, Map context, ModelForm.Banner banner) { 2161 buffer.append("<table width=\"100%\"><tr>"); 2162 String style = banner.getStyle(context); 2163 String leftStyle = banner.getLeftTextStyle(context); 2164 if (UtilValidate.isEmpty(leftStyle)) leftStyle = style; 2165 String rightStyle = banner.getRightTextStyle(context); 2166 if (UtilValidate.isEmpty(rightStyle)) rightStyle = style; 2167 2168 String 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 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 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 2229 public void renderHyperlinkTitle(StringBuffer buffer, Map context, ModelFormField modelFormField, String titleText) { 2230 if (UtilValidate.isNotEmpty(modelFormField.getHeaderLink())) { 2231 StringBuffer targetBuffer = new StringBuffer (); 2232 FlexibleStringExpander target = new FlexibleStringExpander(modelFormField.getHeaderLink()); 2233 String 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 |