1 24 package org.ofbiz.widget.screen; 25 26 import java.io.IOException ; 27 import java.io.Serializable ; 28 import java.io.Writer ; 29 import java.util.ArrayList ; 30 import java.util.HashMap ; 31 import java.util.Iterator ; 32 import java.util.LinkedList ; 33 import java.util.List ; 34 import java.util.Map ; 35 36 import javax.servlet.http.HttpServletRequest ; 37 import javax.servlet.http.HttpServletResponse ; 38 import javax.xml.parsers.ParserConfigurationException ; 39 40 import org.ofbiz.base.util.Debug; 41 import org.ofbiz.base.util.GeneralException; 42 import org.ofbiz.base.util.UtilFormatOut; 43 import org.ofbiz.base.util.UtilValidate; 44 import org.ofbiz.base.util.UtilXml; 45 import org.ofbiz.base.util.UtilMisc; 46 import org.ofbiz.base.util.collections.MapStack; 47 import org.ofbiz.base.util.string.FlexibleStringExpander; 48 import org.ofbiz.widget.form.FormFactory; 49 import org.ofbiz.widget.form.FormStringRenderer; 50 import org.ofbiz.widget.form.ModelForm; 51 import org.ofbiz.widget.html.HtmlFormRenderer; 52 import org.ofbiz.widget.html.HtmlMenuRenderer; 53 import org.ofbiz.widget.html.HtmlTreeRenderer; 54 import org.ofbiz.widget.menu.MenuFactory; 55 import org.ofbiz.widget.menu.MenuStringRenderer; 56 import org.ofbiz.widget.menu.ModelMenu; 57 import org.ofbiz.widget.tree.ModelTree; 58 import org.ofbiz.widget.tree.TreeFactory; 59 import org.ofbiz.widget.tree.TreeStringRenderer; 60 import org.ofbiz.entity.GenericDelegator; 61 import org.ofbiz.entity.GenericValue; 62 import org.ofbiz.entity.GenericEntityException; 63 import org.w3c.dom.Element ; 64 import org.xml.sax.SAXException ; 65 66 73 public abstract class ModelScreenWidget implements Serializable { 74 public static final String module = ModelScreenWidget.class.getName(); 75 76 protected ModelScreen modelScreen; 77 78 public ModelScreenWidget(ModelScreen modelScreen, Element widgetElement) { 79 this.modelScreen = modelScreen; 80 if (Debug.verboseOn()) Debug.logVerbose("Reading Screen sub-widget with name: " + widgetElement.getNodeName(), module); 81 } 82 83 public abstract void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException; 84 85 public abstract String rawString(); 86 87 public static List readSubWidgets(ModelScreen modelScreen, List subElementList) { 88 List subWidgets = new LinkedList (); 89 90 Iterator subElementIter = subElementList.iterator(); 91 while (subElementIter.hasNext()) { 92 Element subElement = (Element ) subElementIter.next(); 93 94 if ("section".equals(subElement.getNodeName())) { 95 subWidgets.add(new Section(modelScreen, subElement)); 96 } else if ("container".equals(subElement.getNodeName())) { 97 subWidgets.add(new Container(modelScreen, subElement)); 98 } else if ("include-screen".equals(subElement.getNodeName())) { 99 subWidgets.add(new IncludeScreen(modelScreen, subElement)); 100 } else if ("decorator-screen".equals(subElement.getNodeName())) { 101 subWidgets.add(new DecoratorScreen(modelScreen, subElement)); 102 } else if ("decorator-section-include".equals(subElement.getNodeName())) { 103 subWidgets.add(new DecoratorSectionInclude(modelScreen, subElement)); 104 } else if ("label".equals(subElement.getNodeName())) { 105 subWidgets.add(new Label(modelScreen, subElement)); 106 } else if ("include-form".equals(subElement.getNodeName())) { 107 subWidgets.add(new Form(modelScreen, subElement)); 108 } else if ("include-menu".equals(subElement.getNodeName())) { 109 subWidgets.add(new Menu(modelScreen, subElement)); 110 } else if ("include-tree".equals(subElement.getNodeName())) { 111 subWidgets.add(new Tree(modelScreen, subElement)); 112 } else if ("content".equals(subElement.getNodeName())) { 113 subWidgets.add(new Content(modelScreen, subElement)); 114 } else if ("sub-content".equals(subElement.getNodeName())) { 115 subWidgets.add(new SubContent(modelScreen, subElement)); 116 } else if ("platform-specific".equals(subElement.getNodeName())) { 117 subWidgets.add(new PlatformSpecific(modelScreen, subElement)); 118 } else if ("link".equals(subElement.getNodeName())) { 119 subWidgets.add(new Link(modelScreen, subElement)); 120 } else if ("image".equals(subElement.getNodeName())) { 121 subWidgets.add(new Image(modelScreen, subElement)); 122 } else if ("iterate-section".equals(subElement.getNodeName())) { 123 subWidgets.add(new IterateSectionWidget(modelScreen, subElement)); 124 } else { 125 throw new IllegalArgumentException ("Found invalid screen widget element with name: " + subElement.getNodeName()); 126 } 127 } 128 129 return subWidgets; 130 } 131 132 public static void renderSubWidgetsString(List subWidgets, Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException { 133 if (subWidgets == null) { 134 return; 135 } 136 Iterator subWidgetIter = subWidgets.iterator(); 137 while (subWidgetIter.hasNext()) { 138 ModelScreenWidget subWidget = (ModelScreenWidget) subWidgetIter.next(); 139 if (Debug.verboseOn()) Debug.logVerbose("Rendering screen " + subWidget.modelScreen.name + " widget " + subWidget.getClass().getName(), module); 140 141 Map parameters = (Map ) context.get("parameters"); 142 boolean insertWidgetBoundaryComments = "true".equals(parameters==null?null:parameters.get("widgetVerbose")); 143 StringBuffer widgetDescription = null; 144 if (insertWidgetBoundaryComments) { 145 widgetDescription = new StringBuffer (); 146 widgetDescription.append("Widget [screen:"); 147 widgetDescription.append(subWidget.modelScreen.name); 148 widgetDescription.append("] "); 149 widgetDescription.append(subWidget.rawString()); 150 151 try { 152 writer.write("<!-- === BEGIN "); 153 writer.write(widgetDescription.toString()); 154 writer.write(" -->\n"); 155 } catch (IOException e) { 156 throw new GeneralException("Error adding verbose sub-widget HTML/XML comments:", e); 157 } 158 } 159 160 subWidget.renderWidgetString(writer, context, screenStringRenderer); 162 163 if (insertWidgetBoundaryComments) { 164 try { 165 writer.write("\n<!-- === END "); 166 writer.write(widgetDescription.toString()); 167 writer.write(" -->\n"); 168 } catch (IOException e) { 169 throw new GeneralException("Error adding verbose sub-widget HTML/XML comments:", e); 170 } 171 } 172 } 173 } 174 175 public static class SectionsRenderer { 176 protected Map sectionMap; 177 protected ScreenStringRenderer screenStringRenderer; 178 protected Map context; 179 protected Writer writer; 180 181 public SectionsRenderer(Map sectionMap, Map context, Writer writer, ScreenStringRenderer screenStringRenderer) { 182 this.sectionMap = sectionMap; 183 this.context = context; 184 this.writer = writer; 185 this.screenStringRenderer = screenStringRenderer; 186 } 187 188 189 public String render(String sectionName) throws GeneralException { 190 ModelScreenWidget section = (ModelScreenWidget) this.sectionMap.get(sectionName); 191 if (section != null) { 193 section.renderWidgetString(this.writer, this.context, this.screenStringRenderer); 194 } 195 return ""; 196 } 197 } 198 199 public static class Section extends ModelScreenWidget { 200 protected String name; 201 protected ModelScreenCondition condition; 202 protected List actions; 203 protected List subWidgets; 204 protected List failWidgets; 205 206 public Section(ModelScreen modelScreen, Element sectionElement) { 207 super(modelScreen, sectionElement); 208 this.name = sectionElement.getAttribute("name"); 209 210 Element conditionElement = UtilXml.firstChildElement(sectionElement, "condition"); 212 if (conditionElement != null) { 213 this.condition = new ModelScreenCondition(modelScreen, conditionElement); 214 } 215 216 Element actionsElement = UtilXml.firstChildElement(sectionElement, "actions"); 218 if (actionsElement != null) { 219 this.actions = ModelScreenAction.readSubActions(modelScreen, actionsElement); 220 } 221 222 Element widgetsElement = UtilXml.firstChildElement(sectionElement, "widgets"); 224 List subElementList = UtilXml.childElementList(widgetsElement); 225 this.subWidgets = ModelScreenWidget.readSubWidgets(this.modelScreen, subElementList); 226 227 Element failWidgetsElement = UtilXml.firstChildElement(sectionElement, "fail-widgets"); 229 if (failWidgetsElement != null) { 230 List failElementList = UtilXml.childElementList(failWidgetsElement); 231 this.failWidgets = ModelScreenWidget.readSubWidgets(this.modelScreen, failElementList); 232 } 233 } 234 235 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException { 236 boolean condTrue = true; 238 if (this.condition != null) { 239 if (!this.condition.eval(context)) { 240 condTrue = false; 241 } 242 } 243 244 if (condTrue) { 246 ModelScreenAction.runSubActions(this.actions, context); 248 249 try { 250 screenStringRenderer.renderSectionBegin(writer, context, this); 252 253 renderSubWidgetsString(this.subWidgets, writer, context, screenStringRenderer); 255 256 screenStringRenderer.renderSectionEnd(writer, context, this); 257 } catch (IOException e) { 258 String errMsg = "Error rendering widgets section [" + this.getName() + "] in screen named [" + this.modelScreen.getName() + "]: " + e.toString(); 259 Debug.logError(e, errMsg, module); 260 throw new RuntimeException (errMsg); 261 } 262 } else { 263 try { 264 screenStringRenderer.renderSectionBegin(writer, context, this); 266 267 renderSubWidgetsString(this.failWidgets, writer, context, screenStringRenderer); 269 270 screenStringRenderer.renderSectionEnd(writer, context, this); 271 } catch (IOException e) { 272 String errMsg = "Error rendering fail-widgets section [" + this.getName() + "] in screen named [" + this.modelScreen.getName() + "]: " + e.toString(); 273 Debug.logError(e, errMsg, module); 274 throw new RuntimeException (errMsg); 275 } 276 } 277 278 } 279 280 public String getName() { 281 return name; 282 } 283 284 public String rawString() { 285 return "<section" + (UtilValidate.isNotEmpty(this.name)?" name=\"" + this.name + "\"":"") + ">"; 286 } 287 } 288 289 public static class Container extends ModelScreenWidget { 290 protected FlexibleStringExpander idExdr; 291 protected FlexibleStringExpander styleExdr; 292 protected List subWidgets; 293 294 public Container(ModelScreen modelScreen, Element containerElement) { 295 super(modelScreen, containerElement); 296 this.idExdr = new FlexibleStringExpander(containerElement.getAttribute("id")); 297 this.styleExdr = new FlexibleStringExpander(containerElement.getAttribute("style")); 298 299 List subElementList = UtilXml.childElementList(containerElement); 301 this.subWidgets = ModelScreenWidget.readSubWidgets(this.modelScreen, subElementList); 302 return; 303 } 304 305 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException { 306 try { 307 screenStringRenderer.renderContainerBegin(writer, context, this); 308 309 renderSubWidgetsString(this.subWidgets, writer, context, screenStringRenderer); 311 312 screenStringRenderer.renderContainerEnd(writer, context, this); 313 } catch (IOException e) { 314 String errMsg = "Error rendering container in screen named [" + this.modelScreen.getName() + "]: " + e.toString(); 315 Debug.logError(e, errMsg, module); 316 throw new RuntimeException (errMsg); 317 } 318 } 319 320 public String getId(Map context) { 321 return this.idExdr.expandString(context); 322 } 323 324 public String getStyle(Map context) { 325 return this.styleExdr.expandString(context); 326 } 327 328 public String rawString() { 329 return "<container id=\"" + this.idExdr.getOriginal() + "\" style=\"" + this.styleExdr.getOriginal() + "\">"; 330 } 331 } 332 333 public static class IncludeScreen extends ModelScreenWidget { 334 protected FlexibleStringExpander nameExdr; 335 protected FlexibleStringExpander locationExdr; 336 protected FlexibleStringExpander shareScopeExdr; 337 338 public IncludeScreen(ModelScreen modelScreen, Element includeScreenElement) { 339 super(modelScreen, includeScreenElement); 340 this.nameExdr = new FlexibleStringExpander(includeScreenElement.getAttribute("name")); 341 this.locationExdr = new FlexibleStringExpander(includeScreenElement.getAttribute("location")); 342 this.shareScopeExdr = new FlexibleStringExpander(includeScreenElement.getAttribute("share-scope")); 343 } 344 345 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException { 346 boolean protectScope = !shareScope(context); 348 if (protectScope) { 349 if (!(context instanceof MapStack)) { 350 context = MapStack.create(context); 351 } 352 353 ((MapStack) context).push(); 354 355 List widgetTrail = (List ) context.get("_WIDGETTRAIL_"); 357 if (widgetTrail == null) { 358 widgetTrail = new ArrayList (); 359 } 360 361 String thisName = nameExdr.expandString(context); 362 widgetTrail.add(thisName); 363 context.put("_WIDGETTRAIL_", widgetTrail); 364 } 365 366 String name = this.getName(context); 368 String location = this.getLocation(context); 369 370 if (UtilValidate.isEmpty(name)) { 371 if (Debug.infoOn()) Debug.logInfo("In the include-screen tag the screen name was empty, ignoring include; in screen [" + this.modelScreen.getName() + "]", module); 372 return; 373 } 374 375 if (ScreenFactory.isCombinedName(name)) { 377 String combinedName = name; 378 location = ScreenFactory.getResourceNameFromCombined(combinedName); 379 name = ScreenFactory.getScreenNameFromCombined(combinedName); 380 } 381 382 ModelScreen modelScreen = null; 383 if (UtilValidate.isNotEmpty(location)) { 384 try { 385 modelScreen = ScreenFactory.getScreenFromLocation(location, name); 386 } catch (IOException e) { 387 String errMsg = "Error rendering included screen named [" + name + "] at location [" + location + "]: " + e.toString(); 388 Debug.logError(e, errMsg, module); 389 throw new RuntimeException (errMsg); 390 } catch (SAXException e) { 391 String errMsg = "Error rendering included screen named [" + name + "] at location [" + location + "]: " + e.toString(); 392 Debug.logError(e, errMsg, module); 393 throw new RuntimeException (errMsg); 394 } catch (ParserConfigurationException e) { 395 String errMsg = "Error rendering included screen named [" + name + "] at location [" + location + "]: " + e.toString(); 396 Debug.logError(e, errMsg, module); 397 throw new RuntimeException (errMsg); 398 } 399 } else { 400 modelScreen = (ModelScreen) this.modelScreen.modelScreenMap.get(name); 401 if (modelScreen == null) { 402 throw new IllegalArgumentException ("Could not find screen with name [" + name + "] in the same file as the screen with name [" + this.modelScreen.getName() + "]"); 403 } 404 } 405 modelScreen.renderScreenString(writer, context, screenStringRenderer); 406 407 if (protectScope) { 408 ((MapStack) context).pop(); 409 } 410 } 411 412 public String getName(Map context) { 413 return this.nameExdr.expandString(context); 414 } 415 416 public String getLocation(Map context) { 417 return this.locationExdr.expandString(context); 418 } 419 420 public boolean shareScope(Map context) { 421 String shareScopeString = this.shareScopeExdr.expandString(context); 422 return "true".equals(shareScopeString); 424 } 425 426 public String rawString() { 427 return "<include-screen name=\"" + this.nameExdr.getOriginal() + "\" location=\"" + this.locationExdr.getOriginal() + "\" share-scope=\"" + this.shareScopeExdr.getOriginal() + "\"/>"; 428 } 429 } 430 431 public static class DecoratorScreen extends ModelScreenWidget { 432 protected FlexibleStringExpander nameExdr; 433 protected FlexibleStringExpander locationExdr; 434 protected Map sectionMap = new HashMap (); 435 436 public DecoratorScreen(ModelScreen modelScreen, Element decoratorScreenElement) { 437 super(modelScreen, decoratorScreenElement); 438 this.nameExdr = new FlexibleStringExpander(decoratorScreenElement.getAttribute("name")); 439 this.locationExdr = new FlexibleStringExpander(decoratorScreenElement.getAttribute("location")); 440 441 List decoratorSectionElementList = UtilXml.childElementList(decoratorScreenElement, "decorator-section"); 442 Iterator decoratorSectionElementIter = decoratorSectionElementList.iterator(); 443 while (decoratorSectionElementIter.hasNext()) { 444 Element decoratorSectionElement = (Element ) decoratorSectionElementIter.next(); 445 String name = decoratorSectionElement.getAttribute("name"); 446 this.sectionMap.put(name, new DecoratorSection(modelScreen, decoratorSectionElement)); 447 } 448 } 449 450 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException { 451 if (!(context instanceof MapStack)) { 453 context = MapStack.create(context); 454 } 455 456 MapStack contextMs = (MapStack) context; 457 458 MapStack standAloneStack = contextMs.standAloneChildStack(); 460 standAloneStack.put("screens", new ScreenRenderer(writer, contextMs, screenStringRenderer)); 461 SectionsRenderer sections = new SectionsRenderer(this.sectionMap, standAloneStack, writer, screenStringRenderer); 462 463 contextMs.push(); 465 context.put("sections", sections); 466 467 String name = this.getName(context); 468 String location = this.getLocation(context); 469 470 if (ScreenFactory.isCombinedName(name)) { 472 String combinedName = name; 473 location = ScreenFactory.getResourceNameFromCombined(combinedName); 474 name = ScreenFactory.getScreenNameFromCombined(combinedName); 475 } 476 477 ModelScreen modelScreen = null; 478 if (UtilValidate.isNotEmpty(location)) { 479 try { 480 modelScreen = ScreenFactory.getScreenFromLocation(location, name); 481 } catch (IOException e) { 482 String errMsg = "Error rendering included screen named [" + name + "] at location [" + location + "]: " + e.toString(); 483 Debug.logError(e, errMsg, module); 484 throw new RuntimeException (errMsg); 485 } catch (SAXException e) { 486 String errMsg = "Error rendering included screen named [" + name + "] at location [" + location + "]: " + e.toString(); 487 Debug.logError(e, errMsg, module); 488 throw new RuntimeException (errMsg); 489 } catch (ParserConfigurationException e) { 490 String errMsg = "Error rendering included screen named [" + name + "] at location [" + location + "]: " + e.toString(); 491 Debug.logError(e, errMsg, module); 492 throw new RuntimeException (errMsg); 493 } 494 } else { 495 modelScreen = (ModelScreen) this.modelScreen.modelScreenMap.get(name); 496 if (modelScreen == null) { 497 throw new IllegalArgumentException ("Could not find screen with name [" + name + "] in the same file as the screen with name [" + this.modelScreen.getName() + "]"); 498 } 499 } 500 modelScreen.renderScreenString(writer, context, screenStringRenderer); 501 502 contextMs.pop(); 503 } 504 505 public String getName(Map context) { 506 return this.nameExdr.expandString(context); 507 } 508 509 public String getLocation(Map context) { 510 return this.locationExdr.expandString(context); 511 } 512 513 public String rawString() { 514 return "<decorator-screen name=\"" + this.nameExdr.getOriginal() + "\" location=\"" + this.locationExdr.getOriginal() + "\"/>"; 515 } 516 } 517 518 public static class DecoratorSection extends ModelScreenWidget { 519 protected String name; 520 protected List subWidgets; 521 522 public DecoratorSection(ModelScreen modelScreen, Element decoratorSectionElement) { 523 super(modelScreen, decoratorSectionElement); 524 this.name = decoratorSectionElement.getAttribute("name"); 525 List subElementList = UtilXml.childElementList(decoratorSectionElement); 527 this.subWidgets = ModelScreenWidget.readSubWidgets(this.modelScreen, subElementList); 528 } 529 530 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException { 531 renderSubWidgetsString(this.subWidgets, writer, context, screenStringRenderer); 533 } 534 535 public String rawString() { 536 return "<decorator-section name=\"" + this.name + "\">"; 537 } 538 } 539 540 public static class DecoratorSectionInclude extends ModelScreenWidget { 541 protected String name; 542 543 public DecoratorSectionInclude(ModelScreen modelScreen, Element decoratorSectionElement) { 544 super(modelScreen, decoratorSectionElement); 545 this.name = decoratorSectionElement.getAttribute("name"); 546 } 547 548 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException { 549 SectionsRenderer sections = (SectionsRenderer) context.get("sections"); 550 if (sections == null) { 552 Debug.logWarning("In decorator-section-include could not find sections object in the context, not rendering section with name [" + this.name + "]", module); 553 } else { 554 sections.render(this.name); 555 } 556 } 557 558 public String rawString() { 559 return "<decorator-section-include name=\"" + this.name + "\">"; 560 } 561 } 562 563 public static class Label extends ModelScreenWidget { 564 protected FlexibleStringExpander textExdr; 565 566 protected FlexibleStringExpander idExdr; 567 protected FlexibleStringExpander styleExdr; 568 569 public Label(ModelScreen modelScreen, Element labelElement) { 570 super(modelScreen, labelElement); 571 572 String textAttr = UtilFormatOut.checkNull(labelElement.getAttribute("text")); 574 String pcdata = UtilFormatOut.checkNull(UtilXml.elementValue(labelElement)); 575 this.textExdr = new FlexibleStringExpander(textAttr + pcdata); 576 577 this.idExdr = new FlexibleStringExpander(labelElement.getAttribute("id")); 578 this.styleExdr = new FlexibleStringExpander(labelElement.getAttribute("style")); 579 } 580 581 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) { 582 try { 583 screenStringRenderer.renderLabel(writer, context, this); 584 } catch (IOException e) { 585 String errMsg = "Error rendering label in screen named [" + this.modelScreen.getName() + "]: " + e.toString(); 586 Debug.logError(e, errMsg, module); 587 throw new RuntimeException (errMsg); 588 } 589 } 590 591 public String getText(Map context) { 592 return this.textExdr.expandString(context); 593 } 594 595 public String getId(Map context) { 596 return this.idExdr.expandString(context); 597 } 598 599 public String getStyle(Map context) { 600 return this.styleExdr.expandString(context); 601 } 602 603 public String rawString() { 604 return "<label id=\"" + this.idExdr.getOriginal() + "\" style=\"" + this.styleExdr.getOriginal() + "\" text=\"" + this.textExdr.getOriginal() + "\"/>"; 605 } 606 } 607 608 public static class Form extends ModelScreenWidget { 609 protected FlexibleStringExpander nameExdr; 610 protected FlexibleStringExpander locationExdr; 611 protected FlexibleStringExpander shareScopeExdr; 612 613 public Form(ModelScreen modelScreen, Element formElement) { 614 super(modelScreen, formElement); 615 616 this.nameExdr = new FlexibleStringExpander(formElement.getAttribute("name")); 617 this.locationExdr = new FlexibleStringExpander(formElement.getAttribute("location")); 618 this.shareScopeExdr = new FlexibleStringExpander(formElement.getAttribute("share-scope")); 619 } 620 621 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) { 622 boolean protectScope = !shareScope(context); 623 if (protectScope) { 624 if (!(context instanceof MapStack)) { 625 context = MapStack.create(context); 626 } 627 ((MapStack) context).push(); 628 } 629 630 String name = this.getName(context); 631 String location = this.getLocation(context); 632 ModelForm modelForm = null; 633 try { 634 modelForm = FormFactory.getFormFromLocation(this.getLocation(context), this.getName(context), this.modelScreen.getDelegator(context), this.modelScreen.getDispatcher(context)); 635 } catch (IOException e) { 636 String errMsg = "Error rendering included form named [" + name + "] at location [" + location + "]: " + e.toString(); 637 Debug.logError(e, errMsg, module); 638 throw new RuntimeException (errMsg); 639 } catch (SAXException e) { 640 String errMsg = "Error rendering included form named [" + name + "] at location [" + location + "]: " + e.toString(); 641 Debug.logError(e, errMsg, module); 642 throw new RuntimeException (errMsg); 643 } catch (ParserConfigurationException e) { 644 String errMsg = "Error rendering included form named [" + name + "] at location [" + location + "]: " + e.toString(); 645 Debug.logError(e, errMsg, module); 646 throw new RuntimeException (errMsg); 647 } 648 649 FormStringRenderer formStringRenderer = (FormStringRenderer) context.get("formStringRenderer"); 651 if (formStringRenderer == null) { 653 HttpServletRequest request = (HttpServletRequest ) context.get("request"); 654 HttpServletResponse response = (HttpServletResponse ) context.get("response"); 655 if (request != null && response != null) { 656 formStringRenderer = new HtmlFormRenderer(request, response); 657 } 658 } 659 if (formStringRenderer == null) { 661 throw new IllegalArgumentException ("Could not find a formStringRenderer in the context, and could not find HTTP request/response objects need to create one."); 662 } 663 664 StringBuffer renderBuffer = new StringBuffer (); 666 modelForm.renderFormString(renderBuffer, context, formStringRenderer); 667 try { 668 writer.write(renderBuffer.toString()); 669 } catch (IOException e) { 670 String errMsg = "Error rendering included form named [" + name + "] at location [" + location + "]: " + e.toString(); 671 Debug.logError(e, errMsg, module); 672 throw new RuntimeException (errMsg); 673 } 674 675 if (protectScope) { 676 ((MapStack) context).pop(); 677 } 678 } 679 680 public String getName(Map context) { 681 return this.nameExdr.expandString(context); 682 } 683 684 public String getLocation(Map context) { 685 return this.locationExdr.expandString(context); 686 } 687 688 public boolean shareScope(Map context) { 689 String shareScopeString = this.shareScopeExdr.expandString(context); 690 return "true".equals(shareScopeString); 692 } 693 694 public String rawString() { 695 return "<include-form name=\"" + this.nameExdr.getOriginal() + "\" location=\"" + this.locationExdr.getOriginal() + "\" share-scope=\"" + this.shareScopeExdr.getOriginal() + "\"/>"; 696 } 697 } 698 699 public static class Tree extends ModelScreenWidget { 700 protected FlexibleStringExpander nameExdr; 701 protected FlexibleStringExpander locationExdr; 702 protected FlexibleStringExpander shareScopeExdr; 703 704 public Tree(ModelScreen modelScreen, Element treeElement) { 705 super(modelScreen, treeElement); 706 707 this.nameExdr = new FlexibleStringExpander(treeElement.getAttribute("name")); 708 this.locationExdr = new FlexibleStringExpander(treeElement.getAttribute("location")); 709 this.shareScopeExdr = new FlexibleStringExpander(treeElement.getAttribute("share-scope")); 710 } 711 712 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException { 713 boolean protectScope = !shareScope(context); 714 if (protectScope) { 715 if (!(context instanceof MapStack)) { 716 context = MapStack.create(context); 717 } 718 ((MapStack) context).push(); 719 } 720 721 String name = this.getName(context); 722 String location = this.getLocation(context); 723 ModelTree modelTree = null; 724 try { 725 modelTree = TreeFactory.getTreeFromLocation(this.getLocation(context), this.getName(context), this.modelScreen.getDelegator(context), this.modelScreen.getDispatcher(context)); 726 } catch (IOException e) { 727 String errMsg = "Error rendering included tree named [" + name + "] at location [" + location + "]: " + e.toString(); 728 Debug.logError(e, errMsg, module); 729 throw new RuntimeException (errMsg); 730 } catch (SAXException e) { 731 String errMsg = "Error rendering included tree named [" + name + "] at location [" + location + "]: " + e.toString(); 732 Debug.logError(e, errMsg, module); 733 throw new RuntimeException (errMsg); 734 } catch (ParserConfigurationException e) { 735 String errMsg = "Error rendering included tree named [" + name + "] at location [" + location + "]: " + e.toString(); 736 Debug.logError(e, errMsg, module); 737 throw new RuntimeException (errMsg); 738 } 739 740 TreeStringRenderer treeStringRenderer = (TreeStringRenderer) context.get("treeStringRenderer"); 742 if (treeStringRenderer == null) { 744 treeStringRenderer = new HtmlTreeRenderer(); 745 752 } 753 if (treeStringRenderer == null) { 755 throw new IllegalArgumentException ("Could not find a treeStringRenderer in the context, and could not find HTTP request/response objects need to create one."); 756 } 757 758 StringBuffer renderBuffer = new StringBuffer (); 759 modelTree.renderTreeString(renderBuffer, context, treeStringRenderer); 760 try { 761 writer.write(renderBuffer.toString()); 762 } catch (IOException e) { 763 String errMsg = "Error rendering included tree named [" + name + "] at location [" + location + "]: " + e.toString(); 764 Debug.logError(e, errMsg, module); 765 throw new RuntimeException (errMsg); 766 } 767 768 if (protectScope) { 769 ((MapStack) context).pop(); 770 } 771 } 772 773 public String getName(Map context) { 774 return this.nameExdr.expandString(context); 775 } 776 777 public String getLocation(Map context) { 778 return this.locationExdr.expandString(context); 779 } 780 781 public boolean shareScope(Map context) { 782 String shareScopeString = this.shareScopeExdr.expandString(context); 783 return "true".equals(shareScopeString); 785 } 786 787 public String rawString() { 788 return "<include-tree name=\"" + this.nameExdr.getOriginal() + "\" location=\"" + this.locationExdr.getOriginal() + "\" share-scope=\"" + this.shareScopeExdr.getOriginal() + "\"/>"; 789 } 790 } 791 792 public static class PlatformSpecific extends ModelScreenWidget { 793 protected ModelScreenWidget subWidget; 794 795 public PlatformSpecific(ModelScreen modelScreen, Element platformSpecificElement) { 796 super(modelScreen, platformSpecificElement); 797 Element childElement = UtilXml.firstChildElement(platformSpecificElement); 798 if ("html".equals(childElement.getNodeName())) { 799 subWidget = new HtmlWidget(modelScreen, childElement); 800 } else { 801 throw new IllegalArgumentException ("Tag not supported under the platform-specific tag with name: " + childElement.getNodeName()); 802 } 803 } 804 805 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException { 806 subWidget.renderWidgetString(writer, context, screenStringRenderer); 807 } 808 809 public String rawString() { 810 return "<platform-specific>" + (this.subWidget==null?"":this.subWidget.rawString()); 811 } 812 } 813 814 public static class Content extends ModelScreenWidget { 815 816 protected FlexibleStringExpander contentId; 817 protected FlexibleStringExpander editRequest; 818 protected FlexibleStringExpander editContainerStyle; 819 protected FlexibleStringExpander enableEditName; 820 protected boolean xmlEscape = false; 821 protected FlexibleStringExpander dataResourceId; 822 protected String width; 823 protected String height; 824 protected String border; 825 826 public Content(ModelScreen modelScreen, Element subContentElement) { 827 super(modelScreen, subContentElement); 828 829 this.contentId = new FlexibleStringExpander(subContentElement.getAttribute("content-id")); 831 this.dataResourceId = new FlexibleStringExpander(subContentElement.getAttribute("dataresource-id")); 832 this.editRequest = new FlexibleStringExpander(subContentElement.getAttribute("edit-request")); 833 this.editContainerStyle = new FlexibleStringExpander(subContentElement.getAttribute("edit-container-style")); 834 this.enableEditName = new FlexibleStringExpander(subContentElement.getAttribute("enable-edit-name")); 835 this.xmlEscape = "true".equals(subContentElement.getAttribute("xml-escape")); 836 this.width = subContentElement.getAttribute("width"); 837 if (UtilValidate.isEmpty(this.width)) this.width="60%"; 838 this.height = subContentElement.getAttribute("height"); 839 if (UtilValidate.isEmpty(this.height)) this.width="400px"; 840 this.border = subContentElement.getAttribute("border"); 841 return; 842 } 843 844 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) { 845 try { 846 GenericDelegator delegator = (GenericDelegator) context.get("delegator"); 851 GenericValue content = null; 852 String expandedDataResourceId = getDataResourceId(context); 853 if (UtilValidate.isEmpty(expandedDataResourceId)) { 854 String expandedContentId = getContentId(context); 855 if (!(context instanceof MapStack)) { 856 context = MapStack.create(context); 857 } 858 859 ((MapStack) context).push(); 863 context.put("contentId", expandedContentId); 864 865 if (UtilValidate.isNotEmpty(expandedContentId)) { 866 content = delegator.findByPrimaryKeyCache("Content", UtilMisc.toMap("contentId", expandedContentId)); 867 } 868 expandedDataResourceId = content.getString("dataResourceId"); 869 } 870 GenericValue dataResource = null; 871 if (UtilValidate.isNotEmpty(expandedDataResourceId)) { 872 dataResource = delegator.findByPrimaryKeyCache("DataResource", UtilMisc.toMap("dataResourceId", expandedDataResourceId)); 873 } 874 875 String mimeTypeId = null; 876 if (dataResource != null) { 877 mimeTypeId = dataResource.getString("mimeTypeId"); 878 } 879 880 if (UtilValidate.isNotEmpty(mimeTypeId) 881 && ((mimeTypeId.indexOf("application") >= 0) || (mimeTypeId.indexOf("image")) >= 0) ) { 882 screenStringRenderer.renderContentFrame(writer, context, this); 883 } else { 884 screenStringRenderer.renderContentBegin(writer, context, this); 885 screenStringRenderer.renderContentBody(writer, context, this); 886 screenStringRenderer.renderContentEnd(writer, context, this); 887 } 888 ((MapStack) context).pop(); 889 } catch (IOException e) { 890 String errMsg = "Error rendering content with contentId [" + getContentId(context) + "]: " + e.toString(); 891 Debug.logError(e, errMsg, module); 892 throw new RuntimeException (errMsg); 893 } catch (GenericEntityException e) { 894 String errMsg = "Error obtaining content with contentId [" + getContentId(context) + "]: " + e.toString(); 895 Debug.logError(e, errMsg, module); 896 throw new RuntimeException (errMsg); 897 } 898 899 } 900 901 public String getContentId(Map context) { 902 return this.contentId.expandString(context); 903 } 904 905 public String getDataResourceId(Map context) { 906 return this.dataResourceId.expandString(context); 907 } 908 909 public String getEditRequest(Map context) { 910 return this.editRequest.expandString(context); 911 } 912 913 public String getEditContainerStyle(Map context) { 914 return this.editContainerStyle.expandString(context); 915 } 916 917 public String getEnableEditName(Map context) { 918 return this.enableEditName.expandString(context); 919 } 920 921 public boolean xmlEscape() { 922 return this.xmlEscape; 923 } 924 925 public String rawString() { 926 return "<content content-id=\"" + this.contentId.getOriginal() + "\" xml-escape=\"" + this.xmlEscape + "\"/>"; 928 } 929 930 public String getWidth() { 931 return this.width; 932 } 933 934 public String getHeight() { 935 return this.height; 936 } 937 938 public String getBorder() { 939 return this.border; 940 } 941 } 942 943 public static class SubContent extends ModelScreenWidget { 944 protected FlexibleStringExpander contentId; 945 protected FlexibleStringExpander assocName; 946 protected FlexibleStringExpander editRequest; 947 protected FlexibleStringExpander editContainerStyle; 948 protected FlexibleStringExpander enableEditName; 949 protected boolean xmlEscape = false; 950 951 public SubContent(ModelScreen modelScreen, Element subContentElement) { 952 super(modelScreen, subContentElement); 953 954 this.contentId = new FlexibleStringExpander(UtilFormatOut.checkNull(subContentElement.getAttribute("content-id"))); 956 this.assocName = new FlexibleStringExpander(UtilFormatOut.checkNull(subContentElement.getAttribute("assoc-name"))); 957 this.editRequest = new FlexibleStringExpander(UtilFormatOut.checkNull(subContentElement.getAttribute("edit-request"))); 958 this.editContainerStyle = new FlexibleStringExpander(subContentElement.getAttribute("edit-container-style")); 959 this.enableEditName = new FlexibleStringExpander(subContentElement.getAttribute("enable-edit-name")); 960 this.xmlEscape = "true".equals(subContentElement.getAttribute("xml-escape")); 961 962 } 963 964 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) { 965 try { 966 screenStringRenderer.renderSubContentBegin(writer, context, this); 967 screenStringRenderer.renderSubContentBody(writer, context, this); 968 screenStringRenderer.renderSubContentEnd(writer, context, this); 969 } catch (IOException e) { 970 String errMsg = "Error rendering subContent with contentId [" + getContentId(context) + "]: " + e.toString(); 971 Debug.logError(e, errMsg, module); 972 throw new RuntimeException (errMsg); 973 } 974 } 975 976 public String getContentId(Map context) { 977 return this.contentId.expandString(context); 978 } 979 980 public String getAssocName(Map context) { 981 return this.assocName.expandString(context); 982 } 983 984 public String getEditRequest(Map context) { 985 return this.editRequest.expandString(context); 986 } 987 988 public String getEditContainerStyle(Map context) { 989 return this.editContainerStyle.expandString(context); 990 } 991 992 public String getEnableEditName(Map context) { 993 return this.enableEditName.expandString(context); 994 } 995 996 public boolean xmlEscape() { 997 return this.xmlEscape; 998 } 999 1000 public String rawString() { 1001 return "<sub-content content-id=\"" + this.contentId.getOriginal() + "\" assoc-name=\"" + this.assocName.getOriginal() + "\" xml-escape=\"" + this.xmlEscape + "\"/>"; 1003 } 1004 } 1005 1006 public static class Menu extends ModelScreenWidget { 1007 protected FlexibleStringExpander nameExdr; 1008 protected FlexibleStringExpander locationExdr; 1009 1010 public Menu(ModelScreen modelScreen, Element menuElement) { 1011 super(modelScreen, menuElement); 1012 1013 this.nameExdr = new FlexibleStringExpander(menuElement.getAttribute("name")); 1014 this.locationExdr = new FlexibleStringExpander(menuElement.getAttribute("location")); 1015 } 1016 1017 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) { 1018 String name = this.getName(context); 1019 String location = this.getLocation(context); 1020 ModelMenu modelMenu = null; 1021 try { 1022 modelMenu = MenuFactory.getMenuFromLocation(this.getLocation(context), this.getName(context), this.modelScreen.getDelegator(context), this.modelScreen.getDispatcher(context)); 1023 } catch (IOException e) { 1024 String errMsg = "Error rendering included menu named [" + name + "] at location [" + location + "]: " + e.toString(); 1025 Debug.logError(e, errMsg, module); 1026 throw new RuntimeException (errMsg); 1027 } catch (SAXException e) { 1028 String errMsg = "Error rendering included menu named [" + name + "] at location [" + location + "]: " + e.toString(); 1029 Debug.logError(e, errMsg, module); 1030 throw new RuntimeException (errMsg); 1031 } catch (ParserConfigurationException e) { 1032 String errMsg = "Error rendering included menu named [" + name + "] at location [" + location + "]: " + e.toString(); 1033 Debug.logError(e, errMsg, module); 1034 throw new RuntimeException (errMsg); 1035 } 1036 1037 MenuStringRenderer menuStringRenderer = (MenuStringRenderer) context.get("menuStringRenderer"); 1039 if (menuStringRenderer == null) { 1041 HttpServletRequest request = (HttpServletRequest ) context.get("request"); 1042 HttpServletResponse response = (HttpServletResponse ) context.get("response"); 1043 if (request != null && response != null) { 1044 menuStringRenderer = new HtmlMenuRenderer(request, response); 1045 } 1046 } 1047 if (menuStringRenderer == null) { 1049 throw new IllegalArgumentException ("Could not find a menuStringRenderer in the context, and could not find HTTP request/response objects need to create one."); 1050 } 1051 1052 StringBuffer renderBuffer = new StringBuffer (); 1053 modelMenu.renderMenuString(renderBuffer, context, menuStringRenderer); 1054 try { 1055 writer.write(renderBuffer.toString()); 1056 } catch (IOException e) { 1057 String errMsg = "Error rendering included menu named [" + name + "] at location [" + location + "]: " + e.toString(); 1058 Debug.logError(e, errMsg, module); 1059 throw new RuntimeException (errMsg); 1060 } 1061 } 1062 1063 public String getName(Map context) { 1064 return this.nameExdr.expandString(context); 1065 } 1066 1067 public String getLocation(Map context) { 1068 return this.locationExdr.expandString(context); 1069 } 1070 1071 public String rawString() { 1072 return "<include-menu name=\"" + this.nameExdr.getOriginal() + "\" location=\"" + this.locationExdr.getOriginal() + "\"/>"; 1073 } 1074 } 1075 1076 public static class Link extends ModelScreenWidget { 1077 protected FlexibleStringExpander textExdr; 1078 protected FlexibleStringExpander idExdr; 1079 protected FlexibleStringExpander styleExdr; 1080 protected FlexibleStringExpander targetExdr; 1081 protected FlexibleStringExpander targetWindowExdr; 1082 protected FlexibleStringExpander prefixExdr; 1083 protected FlexibleStringExpander nameExdr; 1084 protected Image image; 1085 protected String urlMode = "intra-app"; 1086 protected boolean fullPath = false; 1087 protected boolean secure = false; 1088 protected boolean encode = false; 1089 1090 1091 public Link(ModelScreen modelScreen, Element linkElement) { 1092 super(modelScreen, linkElement); 1093 1094 setText(linkElement.getAttribute("text")); 1095 setId(linkElement.getAttribute("id")); 1096 setStyle(linkElement.getAttribute("style")); 1097 setName(linkElement.getAttribute("name")); 1098 setTarget(linkElement.getAttribute("target")); 1099 setTargetWindow(linkElement.getAttribute("target-window")); 1100 setPrefix(linkElement.getAttribute("prefix")); 1101 setUrlMode(linkElement.getAttribute("url-mode")); 1102 setFullPath(linkElement.getAttribute("full-path")); 1103 setSecure(linkElement.getAttribute("secure")); 1104 setEncode(linkElement.getAttribute("encode")); 1105 Element imageElement = UtilXml.firstChildElement(linkElement, "image"); 1106 if (imageElement != null) { 1107 this.image = new Image(modelScreen, imageElement); 1108 } 1109 1110 } 1111 1112 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) { 1113 try { 1114 screenStringRenderer.renderLink(writer, context, this); 1115 } catch (IOException e) { 1116 String errMsg = "Error rendering link with id [" + getId(context) + "]: " + e.toString(); 1117 Debug.logError(e, errMsg, module); 1118 throw new RuntimeException (errMsg); 1119 } 1120 } 1121 1122 public String getText(Map context) { 1123 return this.textExdr.expandString(context); 1124 } 1125 1126 public String getId(Map context) { 1127 return this.idExdr.expandString(context); 1128 } 1129 1130 public String getStyle(Map context) { 1131 return this.styleExdr.expandString(context); 1132 } 1133 1134 public String getTarget(Map context) { 1135 return this.targetExdr.expandString(context); 1136 } 1137 1138 public String getName(Map context) { 1139 return this.nameExdr.expandString(context); 1140 } 1141 1142 public String getTargetWindow(Map context) { 1143 return this.targetWindowExdr.expandString(context); 1144 } 1145 1146 public String getUrlMode() { 1147 return this.urlMode; 1148 } 1149 1150 public String getPrefix(Map context) { 1151 return this.prefixExdr.expandString(context); 1152 } 1153 1154 public boolean getFullPath() { 1155 return this.fullPath; 1156 } 1157 1158 public boolean getSecure() { 1159 return this.secure; 1160 } 1161 1162 public boolean getEncode() { 1163 return this.encode; 1164 } 1165 1166 public Image getImage() { 1167 return this.image; 1168 } 1169 1170 public void setText(String val) { 1171 String textAttr = UtilFormatOut.checkNull(val); 1172 this.textExdr = new FlexibleStringExpander(textAttr); 1173 } 1174 public void setId(String val) { 1175 this.idExdr = new FlexibleStringExpander(val); 1176 } 1177 public void setStyle(String val) { 1178 this.styleExdr = new FlexibleStringExpander(val); 1179 } 1180 public void setTarget(String val) { 1181 this.targetExdr = new FlexibleStringExpander(val); 1182 } 1183 public void setName(String val) { 1184 this.nameExdr = new FlexibleStringExpander(val); 1185 } 1186 public void setTargetWindow(String val) { 1187 this.targetWindowExdr = new FlexibleStringExpander(val); 1188 } 1189 public void setPrefix(String val) { 1190 this.prefixExdr = new FlexibleStringExpander(val); 1191 } 1192 public void setUrlMode(String val) { 1193 if (UtilValidate.isNotEmpty(val)) 1194 this.urlMode = val; 1195 } 1196 public void setFullPath(String val) { 1197 String sFullPath = val; 1198 if (sFullPath != null && sFullPath.equalsIgnoreCase("true")) 1199 this.fullPath = true; 1200 else 1201 this.fullPath = false; 1202 } 1203 1204 public void setSecure(String val) { 1205 String sSecure = val; 1206 if (sSecure != null && sSecure.equalsIgnoreCase("true")) 1207 this.secure = true; 1208 else 1209 this.secure = false; 1210 } 1211 1212 public void setEncode(String val) { 1213 String sEncode = val; 1214 if (sEncode != null && sEncode.equalsIgnoreCase("true")) 1215 this.encode = true; 1216 else 1217 this.encode = false; 1218 } 1219 public void setImage(Image img) { 1220 this.image = img; 1221 } 1222 1223 public String rawString() { 1224 return "<link id=\"" + this.idExdr.getOriginal() + "\" style=\"" + this.styleExdr.getOriginal() + "\" text=\"" + this.textExdr.getOriginal() + "\" target=\"" + this.targetExdr.getOriginal() + "\" name=\"" + this.nameExdr.getOriginal() + "\" url-mode=\"" + this.urlMode + "\"/>"; 1226 } 1227 } 1228 1229 public static class Image extends ModelScreenWidget { 1230 protected FlexibleStringExpander srcExdr; 1231 protected FlexibleStringExpander idExdr; 1232 protected FlexibleStringExpander styleExdr; 1233 protected FlexibleStringExpander widthExdr; 1234 protected FlexibleStringExpander heightExdr; 1235 protected FlexibleStringExpander borderExdr; 1236 protected String urlMode = "content"; 1237 1238 public Image(ModelScreen modelScreen, Element imageElement) { 1239 super(modelScreen, imageElement); 1240 1241 setSrc(imageElement.getAttribute("src")); 1242 setId(imageElement.getAttribute("id")); 1243 setStyle(imageElement.getAttribute("style")); 1244 setWidth(imageElement.getAttribute("width")); 1245 setHeight(imageElement.getAttribute("height")); 1246 setBorder(UtilFormatOut.checkEmpty(imageElement.getAttribute("border"), "0")); 1247 setUrlMode(UtilFormatOut.checkEmpty(imageElement.getAttribute("url-mode"), "content")); 1248 } 1249 1250 public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) { 1251 try { 1252 screenStringRenderer.renderImage(writer, context, this); 1253 } catch (IOException e) { 1254 String errMsg = "Error rendering image with id [" + getId(context) + "]: " + e.toString(); 1255 Debug.logError(e, errMsg, module); 1256 throw new RuntimeException (errMsg); 1257 } 1258 } 1259 1260 public String getSrc(Map context) { 1261 return this.srcExdr.expandString(context); 1262 } 1263 1264 public String getId(Map context) { 1265 return this.idExdr.expandString(context); 1266 } 1267 1268 public String getStyle(Map context) { 1269 return this.styleExdr.expandString(context); 1270 } 1271 1272 public String getWidth(Map context) { 1273 return this.widthExdr.expandString(context); 1274 } 1275 1276 public String getHeight(Map context) { 1277 return this.heightExdr.expandString(context); 1278 } 1279 1280 public String getBorder(Map context) { 1281 return this.borderExdr.expandString(context); 1282 } 1283 1284 public String getUrlMode() { 1285 return this.urlMode; 1286 } 1287 1288 public void setSrc(String val) { 1289 String textAttr = UtilFormatOut.checkNull(val); 1290 this.srcExdr = new FlexibleStringExpander(textAttr); 1291 } 1292 public void setId(String val) { 1293 this.idExdr = new FlexibleStringExpander(val); 1294 } 1295 public void setStyle(String val) { 1296 this.styleExdr = new FlexibleStringExpander(val); 1297 } 1298 public void setWidth(String val) { 1299 this.widthExdr = new FlexibleStringExpander(val); 1300 } 1301 public void setHeight(String val) { 1302 this.heightExdr = new FlexibleStringExpander(val); 1303 } 1304 public void setBorder(String val) { 1305 this.borderExdr = new FlexibleStringExpander(val); 1306 } 1307 public void setUrlMode(String val) { 1308 if (UtilValidate.isEmpty(val)) { 1309 this.urlMode = "content"; 1310 } else { 1311 this.urlMode = val; 1312 } 1313 } 1314 1315 public String rawString() { 1316 return "<image id=\"" + this.idExdr.getOriginal() + "\" style=\"" + this.styleExdr.getOriginal() + "\" SRC=\"" + this.srcExdr.getOriginal() + "\" url-mode=\"" + this.urlMode + "\"/>"; 1318 } 1319 } 1320} 1321 1322 | Popular Tags |