svn commit: r602515 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r602515 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java

adrianc
Author: adrianc
Date: Sat Dec  8 09:20:14 2007
New Revision: 602515

URL: http://svn.apache.org/viewvc?rev=602515&view=rev
Log:
Fixed problem where screen widget DTD allows multiple tags within the <html> element, but the widget code renders only one.

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java?rev=602515&r1=602514&r2=602515&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java Sat Dec  8 09:20:14 2007
@@ -21,6 +21,7 @@
 import java.io.IOException;
 import java.io.Writer;
 import java.net.MalformedURLException;
+import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.List;
@@ -40,23 +41,22 @@
 import freemarker.template.TemplateException;
 
 /**
- * Widget Library - Screen model HTML class
+ * Widget Library - Screen model HTML class.
  */
+@SuppressWarnings("serial")
 public class HtmlWidget extends ModelScreenWidget {
     public static final String module = HtmlWidget.class.getName();
     
-    protected ModelScreenWidget childWidget;
+    protected List<ModelScreenWidget> subWidgets = new ArrayList<ModelScreenWidget>();
     
     public HtmlWidget(ModelScreen modelScreen, Element htmlElement) {
         super(modelScreen, htmlElement);
-        List childElementList = UtilXml.childElementList(htmlElement);
-        Iterator childElementIter = childElementList.iterator();
-        while (childElementIter.hasNext()) {
-            Element childElement = (Element) childElementIter.next();
+        List<? extends Element> childElementList = UtilXml.childElementList(htmlElement);
+        for (Element childElement : childElementList) {
             if ("html-template".equals(childElement.getNodeName())) {
-                this.childWidget = new HtmlTemplate(modelScreen, childElement);
+                this.subWidgets.add(new HtmlTemplate(modelScreen, childElement));
             } else if ("html-template-decorator".equals(childElement.getNodeName())) {
-                this.childWidget = new HtmlTemplateDecorator(modelScreen, childElement);
+                this.subWidgets.add(new HtmlTemplateDecorator(modelScreen, childElement));
             } else {
                 throw new IllegalArgumentException("Tag not supported under the platform-specific -> html tag with name: " + childElement.getNodeName());
             }
@@ -64,11 +64,18 @@
     }
 
     public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException {
-        childWidget.renderWidgetString(writer, context, screenStringRenderer);
+        for (ModelScreenWidget subWidget : subWidgets) {
+            subWidget.renderWidgetString(writer, context, screenStringRenderer);
+        }
     }
 
     public String rawString() {
-        return "<html-widget>" + (this.childWidget==null?"":this.childWidget.rawString());
+        StringBuffer buffer = new StringBuffer("<html-widget>");
+        for (ModelScreenWidget subWidget : subWidgets) {
+            buffer.append(subWidget.rawString());
+        }
+        buffer.append("</html-widget>");
+        return buffer.toString();
     }
     
     public static void renderHtmlTemplate(Writer writer, FlexibleStringExpander locationExdr, Map context) {