svn commit: r602569 - /ofbiz/branches/release4.0/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: r602569 - /ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java

jleroux@apache.org
Author: jleroux
Date: Sat Dec  8 14:21:04 2007
New Revision: 602569

URL: http://svn.apache.org/viewvc?rev=602569&view=rev
Log:
Reverted changes from rev. 602531 (this was simply stupid)

Modified:
    ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java

Modified: ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java?rev=602569&r1=602568&r2=602569&view=diff
==============================================================================
--- ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java (original)
+++ ofbiz/branches/release4.0/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java Sat Dec  8 14:21:04 2007
@@ -21,7 +21,6 @@
 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;
@@ -39,22 +38,23 @@
 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 List<ModelScreenWidget> subWidgets = new ArrayList<ModelScreenWidget>();
+    protected ModelScreenWidget childWidget;
 
     public HtmlWidget(ModelScreen modelScreen, Element htmlElement) {
         super(modelScreen, htmlElement);
-        List<? extends Element> childElementList = UtilXml.childElementList(htmlElement);
-        for (Element childElement : childElementList) {
+        List childElementList = UtilXml.childElementList(htmlElement);
+        Iterator childElementIter = childElementList.iterator();
+        while (childElementIter.hasNext()) {
+            Element childElement = (Element) childElementIter.next();
             if ("html-template".equals(childElement.getNodeName())) {
-                this.subWidgets.add(new HtmlTemplate(modelScreen, childElement));
+                this.childWidget = new HtmlTemplate(modelScreen, childElement);
             } else if ("html-template-decorator".equals(childElement.getNodeName())) {
-                this.subWidgets.add(new HtmlTemplateDecorator(modelScreen, childElement));
+                this.childWidget = new HtmlTemplateDecorator(modelScreen, childElement);
             } else {
                 throw new IllegalArgumentException("Tag not supported under the platform-specific -> html tag with name: " + childElement.getNodeName());
             }
@@ -62,18 +62,11 @@
     }
 
     public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException {
-        for (ModelScreenWidget subWidget : subWidgets) {
-            subWidget.renderWidgetString(writer, context, screenStringRenderer);
-        }
+        childWidget.renderWidgetString(writer, context, screenStringRenderer);
     }
 
     public String rawString() {
-        StringBuffer buffer = new StringBuffer("<html-widget>");
-        for (ModelScreenWidget subWidget : subWidgets) {
-            buffer.append(subWidget.rawString());
-        }
-        buffer.append("</html-widget>");
-        return buffer.toString();
+        return "<html-widget>" + (this.childWidget==null?"":this.childWidget.rawString());
     }
 
     public static void renderHtmlTemplate(Writer writer, FlexibleStringExpander locationExdr, Map context) {