svn commit: r594042 - in /ofbiz/trunk/framework: base/config/ example/webapp/example/WEB-INF/ widget/src/org/ofbiz/widget/ widget/src/org/ofbiz/widget/form/ widget/src/org/ofbiz/widget/html/ widget/src/org/ofbiz/widget/menu/ widget/src/org/ofbiz/widget...

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

svn commit: r594042 - in /ofbiz/trunk/framework: base/config/ example/webapp/example/WEB-INF/ widget/src/org/ofbiz/widget/ widget/src/org/ofbiz/widget/form/ widget/src/org/ofbiz/widget/html/ widget/src/org/ofbiz/widget/menu/ widget/src/org/ofbiz/widget...

jleroux@apache.org
Author: jleroux
Date: Mon Nov 12 00:06:40 2007
New Revision: 594042

URL: http://svn.apache.org/viewvc?rev=594042&view=rev
Log:
A patch from Adrian Crum "Screen widget show where code came from in html" (https://issues.apache.org/jira/browse/OFBIZ-1318) - OFBIZ-1318

Added:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java   (with props)
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java   (with props)
Modified:
    ofbiz/trunk/framework/base/config/debug.properties
    ofbiz/trunk/framework/example/webapp/example/WEB-INF/web.xml
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormFactory.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/HtmlWidget.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java

Modified: ofbiz/trunk/framework/base/config/debug.properties
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/base/config/debug.properties?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/base/config/debug.properties (original)
+++ ofbiz/trunk/framework/base/config/debug.properties Mon Nov 12 00:06:40 2007
@@ -32,3 +32,6 @@
 print.warning=true
 print.error=true
 print.fatal=true
+
+# Enable screen widget boundary comments
+#widget.verbose=true

Modified: ofbiz/trunk/framework/example/webapp/example/WEB-INF/web.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/webapp/example/WEB-INF/web.xml?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/example/webapp/example/WEB-INF/web.xml (original)
+++ ofbiz/trunk/framework/example/webapp/example/WEB-INF/web.xml Mon Nov 12 00:06:40 2007
@@ -36,6 +36,16 @@
         <param-value>component://example/widget/example/CommonScreens.xml</param-value>
         <description>The location of the main-decorator screen to use for this webapp; referred to as a context variable in screen def XML files.</description>
     </context-param>
+    <context-param>
+        <param-name>widgetVerbose</param-name>
+        <param-value>false</param-value>
+        <description>Enable widget boundary comments. See org.ofbiz.widget.ModelWidget.widgetBoundaryCommentsEnabled().</description>
+    </context-param>
+    <context-param>
+        <param-name>compressHTML</param-name>
+        <param-value>false</param-value>
+        <description>Remove unnecessary whitespace from HTML output.</description>
+    </context-param>
     
     <filter>
         <filter-name>ContextFilter</filter-name>

Added: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java?rev=594042&view=auto
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java (added)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java Mon Nov 12 00:06:40 2007
@@ -0,0 +1,112 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.widget;
+
+import java.io.Serializable;
+import java.util.Map;
+import org.w3c.dom.Element;
+import org.ofbiz.base.util.UtilProperties;
+
+/**
+ * Widget Library - Widget model class. ModelWidget is a base class that is
+ * extended by other widget model classes.
+ */
+public class ModelWidget implements Serializable {
+
+    /**
+     * The parameter name used to control widget boundary comments. Currently
+     * set to "widgetVerbose". Set the parameter to "true" to enable widget
+     * boundary comments.<br/><br/>
+     * <code>WEB-INF/web.xml</code> example:<br/><br/>
+     * <code>
+     * &lt;context-param&gt;<br/>
+     * &nbsp;&nbsp;&lt;param-name&gt;widgetVerbose&lt;/param-name&gt;<br/>
+     * &nbsp;&nbsp;&lt;param-value&gt;true&lt;/param-value&gt;<br/>
+     * &lt;/context-param&gt;  
+     * </code><br/><br/>
+     * Screen widget example:<br/><br/>
+     * <code>
+     * &lt;actions&gt;<br/>
+     * &nbsp;&nbsp;&lt;set field="parameters.widgetVerbose" value="true" global="true"/&gt;<br/>
+     * &lt;/actions&gt;
+     * </code>
+     */
+    public static final String enableBoundaryCommentsParam = "widgetVerbose";
+    protected String name;
+    protected boolean enableWidgetBoundaryComments = false;
+    
+    protected ModelWidget() {}
+
+    /**
+     * Derived classes must call this constructor.
+     * @param widgetElement The XML Element for the widget
+     */
+    public ModelWidget(Element widgetElement) {
+        this.name = widgetElement.getAttribute("name");
+    }
+
+    /**
+     * Returns the widget's name.
+     * @return Widget's name
+     */
+    public String getName() {
+        return name;
+    }
+    
+    /**
+     * Returns the widget's name to be used in boundary comments. The default action
+     * is to return the widget's name. Derived classes can override this method to
+     * return a customized name.
+     * @return Name to be used in boundary comments
+     */
+    public String getBoundaryCommentName() {
+        return name;
+    }
+    
+    /**
+     * Returns true if boundary comments are enabled for this widget, otherwise
+     * returns false.
+     * @return True if boundary comments are enabled for this widget
+     */
+    public boolean boundaryCommentsEnabled() {
+        return enableWidgetBoundaryComments;
+    }
+
+    /**
+     * Enables/disables boundary comments for this widget.
+     * @param context The screen rendering context
+     */
+    public void setWidgetBoundaryComments(Map context) {
+        enableWidgetBoundaryComments = widgetBoundaryCommentsEnabled((Map) context.get("parameters"));
+    }
+
+    /**
+     * Returns true if widget boundary comments are enabled. Widget boundary comments are
+     * enabled by setting widgetVerbose true in the parameters Map, or by setting
+     * widget.verbose=true in debug.properties.
+     * @param parameters Optional parameters Map
+     */
+    public static boolean widgetBoundaryCommentsEnabled(Map parameters) {
+        boolean result = "true".equals(UtilProperties.getPropertyValue("debug", "widget.verbose"));
+        if (!result && parameters != null) {
+            result = "true".equals(parameters.get(enableBoundaryCommentsParam));
+        }
+        return result;
+    }
+}

Propchange: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/ModelWidget.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormFactory.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormFactory.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/FormFactory.java Mon Nov 12 00:06:40 2007
@@ -65,7 +65,7 @@
                     URL formFileUrl = null;
                     formFileUrl = FlexibleLocation.resolveLocation(resourceName); //, loader);
                     Document formFileDoc = UtilXml.readXmlDocument(formFileUrl, true);
-                    modelFormMap = readFormDocument(formFileDoc, delegator, dispatcher);
+                    modelFormMap = readFormDocument(formFileDoc, delegator, dispatcher, resourceName);
                     formLocationCache.put(resourceName, modelFormMap);
                 }
             }
@@ -95,7 +95,7 @@
                     
                     URL formFileUrl = servletContext.getResource(resourceName);
                     Document formFileDoc = UtilXml.readXmlDocument(formFileUrl, true);
-                    modelFormMap = readFormDocument(formFileDoc, delegator, dispatcher);
+                    modelFormMap = readFormDocument(formFileDoc, delegator, dispatcher, cacheKey);
                     formWebappCache.put(cacheKey, modelFormMap);
                 }
             }
@@ -108,7 +108,7 @@
         return modelForm;
     }
     
-    public static Map readFormDocument(Document formFileDoc, GenericDelegator delegator, LocalDispatcher dispatcher) {
+    public static Map readFormDocument(Document formFileDoc, GenericDelegator delegator, LocalDispatcher dispatcher, String formLocation) {
         Map modelFormMap = new HashMap();
         if (formFileDoc != null) {
             // read document and construct ModelForm for each form element
@@ -118,6 +118,7 @@
             while (formElementIter.hasNext()) {
                 Element formElement = (Element) formElementIter.next();
                 ModelForm modelForm = new ModelForm(formElement, delegator, dispatcher);
+                modelForm.setFormLocation(formLocation);
                 modelFormMap.put(modelForm.getName(), modelForm);
             }
         }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java Mon Nov 12 00:06:40 2007
@@ -52,13 +52,14 @@
 import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.service.ModelParam;
 import org.ofbiz.service.ModelService;
+import org.ofbiz.widget.ModelWidget;
 
 import org.w3c.dom.Element;
 
 /**
  * Widget Library - Form model class
  */
-public class ModelForm {
+public class ModelForm extends ModelWidget {
 
     public static final String module = ModelForm.class.getName();
     public static final String DEFAULT_FORM_RESULT_LIST_NAME = "defaultFormResultList";
@@ -66,7 +67,7 @@
     protected GenericDelegator delegator;
     protected LocalDispatcher dispatcher;
 
-    protected String name;
+    protected String formLocation;
     protected String type;
     protected FlexibleStringExpander target;
     protected String targetType;
@@ -179,12 +180,14 @@
 
     /** XML Constructor */
     public ModelForm(Element formElement, GenericDelegator delegator, LocalDispatcher dispatcher) {
+        super(formElement);
         this.delegator = delegator;
         this.dispatcher = dispatcher;
         initForm(formElement);
     }
     
     public ModelForm(Element formElement) {
+        super(formElement);
         initForm(formElement);
     }
     
@@ -274,7 +277,6 @@
             }
         }
 
-        this.name = formElement.getAttribute("name");
         if (this.type == null || formElement.hasAttribute("type")) {
             this.type = formElement.getAttribute("type");
         }
@@ -685,6 +687,8 @@
     public void renderFormString(StringBuffer buffer, Map context, FormStringRenderer formStringRenderer) {
         ModelFormAction.runSubActions(this.actions, context);
         
+        setWidgetBoundaryComments(context);
+
         // if this is a list form, don't useRequestParameters
         if ("list".equals(this.type) || "multi".equals(this.type)) {
             context.put("useRequestParameters", Boolean.FALSE);
@@ -1905,6 +1909,10 @@
         return this.type;
     }
 
+    public String getBoundaryCommentName() {
+        return formLocation + "#" + name;
+    }
+    
     public void resetBshInterpreter(Map context) {
         context.remove("bshInterpreter");
     }
@@ -2021,6 +2029,13 @@
      */
     public void setItemIndexSeparator(String string) {
         this.itemIndexSeparator = string;
+    }
+
+    /**
+     * @param string Form's location
+     */
+    public void setFormLocation(String formLocation) {
+        this.formLocation = formLocation;
     }
 
     /**

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Mon Nov 12 00:06:40 2007
@@ -1087,13 +1087,13 @@
                     condTrue = boolVal.booleanValue();
                 } else {
                     throw new IllegalArgumentException("Return value from use-when condition eval was not a Boolean: "
-                            + retVal.getClass().getName() + " [" + retVal + "] on the field " + this.name + " of form " + this.modelForm.name);
+                            + retVal.getClass().getName() + " [" + retVal + "] on the field " + this.name + " of form " + this.modelForm.getName());
                 }
 
                 return condTrue;
             } catch (EvalError e) {
                 String errMsg = "Error evaluating BeanShell use-when condition [" + useWhenStr + "] on the field "
-                        + this.name + " of form " + this.modelForm.name + ": " + e.toString();
+                        + this.name + " of form " + this.modelForm.getName() + ": " + e.toString();
                 Debug.logError(e, errMsg, module);
                 //Debug.logError("For use-when eval error context is: " + context, module);
                 throw new IllegalArgumentException(errMsg);

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Mon Nov 12 00:06:40 2007
@@ -31,7 +31,6 @@
 import javax.servlet.http.HttpServletResponse;
 
 import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.UtilFormatOut;
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilProperties;
 import org.ofbiz.base.util.UtilValidate;
@@ -68,7 +67,7 @@
 /**
  * Widget Library - HTML Form Renderer implementation
  */
-public class HtmlFormRenderer implements FormStringRenderer {
+public class HtmlFormRenderer extends HtmlWidgetRenderer implements FormStringRenderer {
 
     public static final String module = HtmlFormRenderer.class.getName();
     
@@ -83,12 +82,6 @@
         this.response = response;
     }
 
-    public void appendWhitespace(StringBuffer buffer) {
-        // appending line ends for now, but this could be replaced with a simple space or something
-        buffer.append("\r\n");
-        //buffer.append(' ');
-    }
-
     public void appendOfbizUrl(StringBuffer buffer, String location) {
         ServletContext ctx = (ServletContext) this.request.getAttribute("servletContext");
         RequestHandler rh = (RequestHandler) ctx.getAttribute("_REQUEST_HANDLER_");
@@ -184,7 +177,7 @@
         
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -202,7 +195,7 @@
             modelFormField.getEvent(),
             modelFormField.getAction(context));
         this.appendTooltip(buffer, context, modelFormField);
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     public void makeHyperlinkString(StringBuffer buffer, ModelFormField.SubHyperlink subHyperlink, Map context) {
@@ -284,7 +277,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -355,7 +348,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -544,7 +537,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -698,7 +691,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -756,7 +749,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -811,7 +804,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -906,7 +899,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -934,7 +927,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -960,8 +953,7 @@
         }
 
         buffer.append("/>");
-
-        //this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -996,7 +988,7 @@
                 buffer.append("</span>");
             }
 
-            //this.appendWhitespace(buffer);
+            //appendWhitespace(buffer);
         }
     }
 
@@ -1022,7 +1014,7 @@
                 buffer.append("</span>");
             }
 
-            //this.appendWhitespace(buffer);
+            //appendWhitespace(buffer);
         } else {
             renderFieldTitle(buffer, context, modelFormField);
         }
@@ -1032,8 +1024,7 @@
      * @see org.ofbiz.widget.form.FormStringRenderer#renderFormOpen(java.lang.StringBuffer, java.util.Map, org.ofbiz.widget.form.ModelForm)
      */
     public void renderFormOpen(StringBuffer buffer, Map context, ModelForm modelForm) {
-        buffer.append("<!-- begin form widget -->");
-        this.appendWhitespace(buffer);
+        renderBeginningBoundaryComment(buffer, "Form Widget", modelForm);
         buffer.append("<form method=\"post\" ");
         String targetType = modelForm.getTargetType();
         String targ = modelForm.getTarget(context, targetType);
@@ -1080,7 +1071,7 @@
         buffer.append(modelForm.getCurrentFormName(context));
         buffer.append("\">");
 
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1090,18 +1081,16 @@
         buffer.append("</form>");
         String focusFieldName = modelForm.getfocusFieldName();
         if (UtilValidate.isNotEmpty(focusFieldName)) {
-            this.appendWhitespace(buffer);
+            appendWhitespace(buffer);
             buffer.append("<script language=\"JavaScript\" type=\"text/javascript\">");
-            this.appendWhitespace(buffer);
+            appendWhitespace(buffer);
             buffer.append("document." + modelForm.getCurrentFormName(context) + ".");
             buffer.append(focusFieldName + ".focus();");
-            this.appendWhitespace(buffer);
+            appendWhitespace(buffer);
             buffer.append("</script>");
         }
-        this.appendWhitespace(buffer);
-        buffer.append("<!-- end form widget -->");
-
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
+        renderEndingBoundaryComment(buffer, "Form Widget", modelForm);
     }
 
     /* (non-Javadoc)
@@ -1145,10 +1134,8 @@
             }
         }
         buffer.append("</form>");
-        this.appendWhitespace(buffer);
-        buffer.append("<!-- end form widget -->");
-
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
+        renderEndingBoundaryComment(buffer, "Form Widget", modelForm);
     }
 
     public void renderFormatListWrapperOpen(StringBuffer buffer, Map context, ModelForm modelForm) {
@@ -1166,8 +1153,7 @@
         }
         context.put("_QBESTRING_", queryString);
 
-        buffer.append("<!-- begin form widget -->");
-        this.appendWhitespace(buffer);
+        renderBeginningBoundaryComment(buffer, "Form Widget", modelForm);
         this.renderNextPrev(buffer, context, modelForm);
         buffer.append(" <table cellspacing=\"0\" class=\"");
         if(UtilValidate.isNotEmpty(modelForm.getDefaultTableStyle())) {
@@ -1176,16 +1162,15 @@
             buffer.append("basic-table form-widget-table dark-grid");
         }
         buffer.append("\">");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     public void renderFormatListWrapperClose(StringBuffer buffer, Map context, ModelForm modelForm) {
         buffer.append(" </table>");
 
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
         this.renderNextPrev(buffer, context, modelForm);
-        buffer.append("<!-- end form widget -->");
-        this.appendWhitespace(buffer);
+        renderEndingBoundaryComment(buffer, "Form Widget", modelForm);
     }
 
     /* (non-Javadoc)
@@ -1201,7 +1186,7 @@
             buffer.append("header-row");
         }
         buffer.append("\">");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1210,7 +1195,7 @@
     public void renderFormatHeaderRowClose(StringBuffer buffer, Map context, ModelForm modelForm) {
         buffer.append("  </tr>");
 
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1230,7 +1215,7 @@
             buffer.append("\"");
         }
         buffer.append(">");
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1238,7 +1223,7 @@
      */
     public void renderFormatHeaderRowCellClose(StringBuffer buffer, Map context, ModelForm modelForm, ModelFormField modelFormField) {
         buffer.append("</td>");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     public void renderFormatHeaderRowFormCellOpen(StringBuffer buffer, Map context, ModelForm modelForm) {
@@ -1250,7 +1235,7 @@
             buffer.append("\"");
         }
         buffer.append(">");
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1258,7 +1243,7 @@
      */
     public void renderFormatHeaderRowFormCellClose(StringBuffer buffer, Map context, ModelForm modelForm) {
         buffer.append("</td>");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1308,7 +1293,7 @@
             }
         }
         buffer.append(">");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1317,7 +1302,7 @@
     public void renderFormatItemRowClose(StringBuffer buffer, Map context, ModelForm modelForm) {
         buffer.append("  </tr>");
 
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1337,7 +1322,7 @@
             buffer.append("\"");
         }
         buffer.append(">");
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1345,7 +1330,7 @@
      */
     public void renderFormatItemRowCellClose(StringBuffer buffer, Map context, ModelForm modelForm, ModelFormField modelFormField) {
         buffer.append("</td>");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1360,7 +1345,7 @@
             buffer.append("\"");
         }
         buffer.append(">");
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1368,19 +1353,21 @@
      */
     public void renderFormatItemRowFormCellClose(StringBuffer buffer, Map context, ModelForm modelForm) {
         buffer.append("</td>");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     public void renderFormatSingleWrapperOpen(StringBuffer buffer, Map context, ModelForm modelForm) {
-        buffer.append(" <table cellspacing=\"0\">");
-
-        this.appendWhitespace(buffer);
+        buffer.append(" <table cellspacing=\"0\"");
+        if(UtilValidate.isNotEmpty(modelForm.getDefaultTableStyle())) {
+            buffer.append(" class=\"" + modelForm.getDefaultTableStyle() + "\"");
+        }
+        buffer.append(">");
+        appendWhitespace(buffer);
     }
 
     public void renderFormatSingleWrapperClose(StringBuffer buffer, Map context, ModelForm modelForm) {
         buffer.append(" </table>");
-
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1388,8 +1375,7 @@
      */
     public void renderFormatFieldRowOpen(StringBuffer buffer, Map context, ModelForm modelForm) {
         buffer.append("  <tr>");
-
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1397,8 +1383,7 @@
      */
     public void renderFormatFieldRowClose(StringBuffer buffer, Map context, ModelForm modelForm) {
         buffer.append("  </tr>");
-
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1415,7 +1400,7 @@
             buffer.append(" class=\"label\"");
         }
         buffer.append(">");
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1423,7 +1408,7 @@
      */
     public void renderFormatFieldRowTitleCellClose(StringBuffer buffer, Map context, ModelFormField modelFormField) {
         buffer.append("</td>");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1433,7 +1418,7 @@
         // Embedded styling - bad idea
         //buffer.append("<td>&nbsp;</td>");
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1463,7 +1448,7 @@
         }
         buffer.append(">");
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1471,7 +1456,7 @@
      */
     public void renderFormatFieldRowWidgetCellClose(StringBuffer buffer, Map context, ModelFormField modelFormField, int positions, int positionSpan, Integer nextPositionInRow) {
         buffer.append("</td>");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     public void renderFormatEmptySpace(StringBuffer buffer, Map context, ModelForm modelForm) {
@@ -1550,7 +1535,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1660,7 +1645,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1862,7 +1847,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -1939,7 +1924,7 @@
         this.makeHyperlinkString(buffer, lookupField.getSubHyperlink(), context);
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     public void renderNextPrev(StringBuffer buffer, Map context, ModelForm modelForm) {
@@ -2101,7 +2086,7 @@
         buffer.append("</li>");
 
         buffer.append("</ul>").append("</div>");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -2142,7 +2127,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -2192,7 +2177,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -2246,7 +2231,7 @@
 
         this.appendTooltip(buffer, context, modelFormField);
 
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
     
     public void renderFieldGroupOpen(StringBuffer buffer, Map context, ModelForm.FieldGroup fieldGroup) {

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java Mon Nov 12 00:06:40 2007
@@ -79,6 +79,8 @@
         
         //make sure the locale is in the context
         context.put("locale", UtilHttp.getLocale(request));
+        //make sure the timeZone is in the context
+        context.put("timeZone", UtilHttp.getTimeZone(request));
         
         // if there was an error message, this is an error
         if (UtilValidate.isNotEmpty((String) request.getAttribute("_ERROR_MESSAGE_"))) {

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlMenuRenderer.java Mon Nov 12 00:06:40 2007
@@ -42,7 +42,7 @@
 /**
  * Widget Library - HTML Menu Renderer implementation
  */
-public class HtmlMenuRenderer implements MenuStringRenderer {
+public class HtmlMenuRenderer extends HtmlWidgetRenderer implements MenuStringRenderer {
 
     HttpServletRequest request;
     HttpServletResponse response;
@@ -59,12 +59,6 @@
         this.response = response;
     }
 
-    public void appendWhitespace(StringBuffer buffer) {
-        // appending line ends for now, but this could be replaced with a simple space or something
-        buffer.append("\r\n");
-        //buffer.append(' ');
-    }
-
     public void appendOfbizUrl(StringBuffer buffer, String location) {
         ServletContext ctx = (ServletContext) request.getAttribute("servletContext");
         if (ctx == null) {
@@ -189,7 +183,7 @@
 
         buffer.append("</li>");
         
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     public boolean isDisableIfEmpty(ModelMenuItem menuItem, Map context) {
@@ -224,8 +218,7 @@
         }
 
             //Debug.logInfo("in HtmlMenuRenderer, userLoginIdHasChanged:" + userLoginIdHasChanged,"");
-        buffer.append("<!-- begin menu widget -->");
-        this.appendWhitespace(buffer);
+        renderBeginningBoundaryComment(buffer, "Menu Widget", modelMenu);
         buffer.append("<div");
         String menuId = modelMenu.getId();
         if (UtilValidate.isNotEmpty(menuId)) {
@@ -245,13 +238,13 @@
         buffer.append(">");
         String menuTitle = modelMenu.getTitle(context);
         if (UtilValidate.isNotEmpty(menuTitle)) {
-            this.appendWhitespace(buffer);
+            appendWhitespace(buffer);
             buffer.append(" <h2>" + menuTitle + "</h2>");
         }
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
         buffer.append(" <ul>");
         
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
     }
 
     /* (non-Javadoc)
@@ -264,13 +257,12 @@
         }
         //String menuContainerStyle = modelMenu.getMenuContainerStyle(context);
         buffer.append(" </ul>");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
         buffer.append(" <br class=\"clear\" />");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
         buffer.append("</div>");
-        this.appendWhitespace(buffer);
-        buffer.append("<!-- end menu widget -->");
-        this.appendWhitespace(buffer);
+        appendWhitespace(buffer);
+        renderEndingBoundaryComment(buffer, "Menu Widget", modelMenu);
         
         userLoginIdHasChanged = userLoginIdHasChanged();
         GenericValue userLogin = (GenericValue)request.getSession().getAttribute("userLogin");
@@ -285,11 +277,11 @@
     }
 
     public void renderFormatSimpleWrapperOpen(StringBuffer buffer, Map context, ModelMenu modelMenu) {
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     public void renderFormatSimpleWrapperClose(StringBuffer buffer, Map context, ModelMenu modelMenu) {
-        //this.appendWhitespace(buffer);
+        //appendWhitespace(buffer);
     }
 
     public void setRequest(HttpServletRequest request) {

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlScreenRenderer.java Mon Nov 12 00:06:40 2007
@@ -37,6 +37,7 @@
 import org.ofbiz.entity.GenericValue;
 import org.ofbiz.webapp.control.RequestHandler;
 import org.ofbiz.webapp.taglib.ContentUrlTag;
+import org.ofbiz.widget.html.HtmlWidgetRenderer;
 import org.ofbiz.widget.WidgetContentWorker;
 import org.ofbiz.widget.WidgetDataResourceWorker;
 import org.ofbiz.widget.screen.ModelScreenWidget;
@@ -47,17 +48,17 @@
 /**
  * Widget Library - HTML Form Renderer implementation
  */
-public class HtmlScreenRenderer implements ScreenStringRenderer {
+public class HtmlScreenRenderer extends HtmlWidgetRenderer implements ScreenStringRenderer {
 
     public static final String module = HtmlScreenRenderer.class.getName();
 
     public HtmlScreenRenderer() {}
 
     public void renderSectionBegin(Writer writer, Map context, ModelScreenWidget.Section section) throws IOException {
-        // do nothing, this is just a place holder container for HTML
+        renderBeginningBoundaryComment(writer, section.isMainSection?"Screen":"Section Widget", section);
     }
     public void renderSectionEnd(Writer writer, Map context, ModelScreenWidget.Section section) throws IOException {
-        // do nothing, this is just a place holder container for HTML
+        renderEndingBoundaryComment(writer, section.isMainSection?"Screen":"Section Widget", section);
     }
 
     public void renderContainerBegin(Writer writer, Map context, ModelScreenWidget.Container container) throws IOException {
@@ -514,11 +515,5 @@
             }
             appendWhitespace(writer);
         }
-    }
-
-    public void appendWhitespace(Writer writer) throws IOException {
-        // appending line ends for now, but this could be replaced with a simple space or something
-        writer.write("\r\n");
-        //writer.write(' ');
     }
 }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlTreeRenderer.java Mon Nov 12 00:06:40 2007
@@ -40,7 +40,7 @@
 /**
  * Widget Library - HTML Tree Renderer implementation
  */
-public class HtmlTreeRenderer implements TreeStringRenderer {
+public class HtmlTreeRenderer extends HtmlWidgetRenderer implements TreeStringRenderer {
 
     ScreenStringRenderer screenStringRenderer = null;
     public static final String module = HtmlTreeRenderer.class.getName();
@@ -68,6 +68,7 @@
         context.put("depth", Integer.toString(depth));
         if (node.isRootNode()) {
             appendWhitespace(writer);
+            renderBeginningBoundaryComment(writer, "Tree Widget", node.getModelTree());
             writer.write("<ul class=\"basic-tree\">");
         }
         appendWhitespace(writer);
@@ -170,6 +171,7 @@
             appendWhitespace(writer);
             writer.write("</ul>");
             appendWhitespace(writer);
+            renderEndingBoundaryComment(writer, "Tree Widget", node.getModelTree());
         }
     }
 
@@ -354,12 +356,6 @@
         }
         writer.write("/>");
         
-    }
-
-    public void appendWhitespace(Writer writer) throws IOException {
-        // appending line ends for now, but this could be replaced with a simple space or something
-        writer.write("\r\n");
-        //writer.write(' ');
     }
 
     public ScreenStringRenderer getScreenStringRenderer(Map context) {

Added: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java?rev=594042&view=auto
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java (added)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java Mon Nov 12 00:06:40 2007
@@ -0,0 +1,111 @@
+/*******************************************************************************
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ *******************************************************************************/
+package org.ofbiz.widget.html;
+
+import java.io.IOException;
+import java.io.Writer;
+import org.ofbiz.widget.ModelWidget;
+
+/**
+ * Widget Library - HTML Widget Renderer implementation. HtmlWidgetRenderer
+ * is a base class that is extended by other widget HTML rendering classes.
+ */
+public class HtmlWidgetRenderer {
+
+    /**
+     * Characters that are appended to the end of each rendered element. Currently set to
+     * CR/LF.
+     */
+    public static final String whiteSpace = "\r\n";
+
+    /**
+     * Helper method used to append whitespace characters to the end of each rendered element.
+     * @param writer The writer to write to
+     */
+    public static void appendWhitespace(Writer writer) throws IOException {
+        writer.write(whiteSpace);
+    }
+    
+    /**
+     * Helper method used to append whitespace characters to the end of each rendered element.
+     * @param buffer The buffer to write to
+     */
+    public static void appendWhitespace(StringBuffer buffer) {
+        buffer.append(whiteSpace);
+    }
+
+    /**
+     * Helper method used to build the boundary comment string.
+     * @param boundaryType The boundary type: "Begin" or "End"
+     * @param widgetType The widget type: "Screen Widget", "Form Widget", etc.
+     * @param widgetName The widget name
+     */
+    public static String buildBoundaryComment(String boundaryType, String widgetType, String widgetName) {
+        return "<!-- " + boundaryType + " " + widgetType + " " + widgetName + " -->" + whiteSpace;
+    }
+
+    /**
+     * Renders the beginning boundary comment string.
+     * @param buffer The buffer to write to
+     * @param widgetType The widget type: "Screen Widget", "Form Widget", etc.
+     * @param modelWidget The widget
+     */
+    public void renderBeginningBoundaryComment(StringBuffer buffer, String widgetType, ModelWidget modelWidget) {
+        if (modelWidget.boundaryCommentsEnabled()) {
+            buffer.append(buildBoundaryComment("Begin", widgetType, modelWidget.getBoundaryCommentName()));
+        }
+    }
+
+    /**
+     * Renders the beginning boundary comment string.
+     * @param writer The writer to write to
+     * @param widgetType The widget type: "Screen Widget", "Form Widget", etc.
+     * @param modelWidget The widget
+     */
+    public void renderBeginningBoundaryComment(Writer writer, String widgetType, ModelWidget modelWidget) throws IOException {
+        if (modelWidget.boundaryCommentsEnabled()) {
+            writer.write(buildBoundaryComment("Begin", widgetType, modelWidget.getBoundaryCommentName()));
+        }
+    }
+
+    /**
+     * Renders the ending boundary comment string.
+     * @param writer The writer to write to
+     * @param widgetType The widget type: "Screen Widget", "Form Widget", etc.
+     * @param modelWidget The widget
+     */
+    public void renderEndingBoundaryComment(Writer writer, String widgetType, ModelWidget modelWidget) throws IOException {
+        if (modelWidget.boundaryCommentsEnabled()) {
+            writer.write(buildBoundaryComment("End", widgetType, modelWidget.getBoundaryCommentName()));
+        }
+    }
+
+    /**
+     * Renders the ending boundary comment string.
+     * @param buffer The buffer to write to
+     * @param widgetType The widget type: "Screen Widget", "Form Widget", etc.
+     * @param modelWidget The widget
+     */
+    public void renderEndingBoundaryComment(StringBuffer buffer, String widgetType, ModelWidget modelWidget) {
+        if (modelWidget.boundaryCommentsEnabled()) {
+            buffer.append(buildBoundaryComment("End", widgetType, modelWidget.getBoundaryCommentName()));
+        }
+    }
+    
+}

Propchange: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java
------------------------------------------------------------------------------
    svn:keywords = "Date Rev Author URL Id"

Propchange: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java
------------------------------------------------------------------------------
    svn:mime-type = text/plain

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MenuFactory.java Mon Nov 12 00:06:40 2007
@@ -68,7 +68,7 @@
                     
                     URL menuFileUrl = servletContext.getResource(resourceName);
                     Document menuFileDoc = UtilXml.readXmlDocument(menuFileUrl, true);
-                    modelMenuMap = readMenuDocument(menuFileDoc, delegator, dispatcher);
+                    modelMenuMap = readMenuDocument(menuFileDoc, delegator, dispatcher, cacheKey);
                     menuWebappCache.put(cacheKey, modelMenuMap);
                 }
             }
@@ -85,7 +85,7 @@
         return modelMenu;
     }
     
-    public static Map readMenuDocument(Document menuFileDoc, GenericDelegator delegator, LocalDispatcher dispatcher) {
+    public static Map readMenuDocument(Document menuFileDoc, GenericDelegator delegator, LocalDispatcher dispatcher, String menuLocation) {
         Map modelMenuMap = new HashMap();
         if (menuFileDoc != null) {
             // read document and construct ModelMenu for each menu element
@@ -95,6 +95,7 @@
             while (menuElementIter.hasNext()) {
                 Element menuElement = (Element) menuElementIter.next();
                 ModelMenu modelMenu = new ModelMenu(menuElement, delegator, dispatcher);
+                modelMenu.setMenuLocation(menuLocation);
                 modelMenuMap.put(modelMenu.getName(), modelMenu);
             }
         }
@@ -116,7 +117,7 @@
                     URL menuFileUrl = null;
                     menuFileUrl = FlexibleLocation.resolveLocation(resourceName); //, loader);
                     Document menuFileDoc = UtilXml.readXmlDocument(menuFileUrl, true);
-                    modelMenuMap = readMenuDocument(menuFileDoc, delegator, dispatcher);
+                    modelMenuMap = readMenuDocument(menuFileDoc, delegator, dispatcher, resourceName);
                     menuLocationCache.put(resourceName, modelMenuMap);
                 }
             }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java Mon Nov 12 00:06:40 2007
@@ -32,6 +32,7 @@
 import org.ofbiz.base.util.collections.FlexibleMapAccessor;
 import org.ofbiz.entity.GenericDelegator;
 import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.widget.ModelWidget;
 import org.w3c.dom.Element;
 
 import bsh.EvalError;
@@ -40,14 +41,14 @@
 /**
  * Widget Library - Menu model class
  */
-public class ModelMenu {
+public class ModelMenu extends ModelWidget {
 
     public static final String module = ModelMenu.class.getName();
 
     protected GenericDelegator delegator;
     protected LocalDispatcher dispatcher;
 
-    protected String name;
+    protected String menuLocation;
     protected String type;
     protected String target;
     protected String id;
@@ -102,6 +103,7 @@
 
     /** XML Constructor */
     public ModelMenu(Element menuElement, GenericDelegator delegator, LocalDispatcher dispatcher) {
+        super(menuElement);
         this.delegator = delegator;
         this.dispatcher = dispatcher;
 
@@ -167,7 +169,6 @@
             }
         }
 
-        this.name = menuElement.getAttribute("name");
         if (this.type == null || menuElement.hasAttribute("type"))
             this.type = menuElement.getAttribute("type");
         if (this.target == null || menuElement.hasAttribute("target"))
@@ -301,7 +302,8 @@
      *   use the same menu definitions for many types of menu UIs
      */
     public void renderMenuString(StringBuffer buffer, Map context, MenuStringRenderer menuStringRenderer) {
-        
+        setWidgetBoundaryComments(context);
+
         boolean passed = true;
 
             //Debug.logInfo("in ModelMenu, name:" + this.getName(), module);
@@ -439,14 +441,6 @@
             return this.defaultMenuItemName;
     }
 
-
-    /**
-     * @return
-     */
-    public String getName() {
-        return this.name;
-    }
-
     public String getCurrentMenuName(Map context) {
         return this.name;
     }
@@ -479,6 +473,10 @@
         return this.type;
     }
 
+    public String getBoundaryCommentName() {
+        return menuLocation + "#" + name;
+    }
+    
     public Interpreter getBshInterpreter(Map context) throws EvalError {
         Interpreter bsh = (Interpreter) context.get("bshInterpreter");
         if (bsh == null) {
@@ -538,6 +536,12 @@
         this.currentMenuItemName = string;
     }
 
+    /**
+     * @param string
+     */
+    public void setMenuLocation(String menuLocation) {
+        this.menuLocation = menuLocation;
+    }
 
     /**
      * @param string

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=594042&r1=594041&r2=594042&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 Mon Nov 12 00:06:40 2007
@@ -33,6 +33,8 @@
 import org.ofbiz.base.util.collections.MapStack;
 import org.ofbiz.base.util.string.FlexibleStringExpander;
 import org.ofbiz.base.util.template.FreeMarkerWorker;
+import org.ofbiz.widget.ModelWidget;
+import org.ofbiz.widget.html.HtmlWidgetRenderer;
 import org.w3c.dom.Element;
 
 import freemarker.template.TemplateException;
@@ -79,7 +81,15 @@
         
         if (location.endsWith(".ftl")) {
             try {
+                Map parameters = (Map) context.get("parameters");
+                boolean insertWidgetBoundaryComments = ModelWidget.widgetBoundaryCommentsEnabled(parameters);
+                if (insertWidgetBoundaryComments) {
+                    writer.write(HtmlWidgetRenderer.buildBoundaryComment("Begin", "Template", location));
+                }
                 FreeMarkerWorker.renderTemplateAtLocation(location, context, writer);
+                if (insertWidgetBoundaryComments) {
+                    writer.write(HtmlWidgetRenderer.buildBoundaryComment("End", "Template", location));
+                }
             } catch (MalformedURLException e) {
                 String errMsg = "Error rendering included template at location [" + location + "]: " + e.toString();
                 Debug.logError(e, errMsg, module);
@@ -187,8 +197,4 @@
         }
     }
 }
-
-
-
-
 

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreen.java Mon Nov 12 00:06:40 2007
@@ -23,7 +23,6 @@
 import java.util.Map;
 
 import org.ofbiz.base.util.Debug;
-import org.ofbiz.base.util.GeneralException;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.UtilXml;
 import org.ofbiz.base.util.string.FlexibleStringExpander;
@@ -32,16 +31,16 @@
 import org.ofbiz.entity.GenericEntityException;
 import org.ofbiz.entity.transaction.TransactionUtil;
 import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.widget.ModelWidget;
 import org.w3c.dom.Element;
 
 /**
  * Widget Library - Screen model class
  */
-public class ModelScreen implements Serializable {
+public class ModelScreen extends ModelWidget implements Serializable {
 
     public static final String module = ModelScreen.class.getName();
 
-    protected String name;
     protected String sourceLocation;
     protected FlexibleStringExpander transactionTimeoutExdr;
     protected Map modelScreenMap;
@@ -55,8 +54,8 @@
 
     /** XML Constructor */
     public ModelScreen(Element screenElement, Map modelScreenMap, String sourceLocation) {
+        super(screenElement);
         this.sourceLocation = sourceLocation;
-        this.name = screenElement.getAttribute("name");
         this.transactionTimeoutExdr = new FlexibleStringExpander(screenElement.getAttribute("transaction-timeout"));
         this.modelScreenMap = modelScreenMap;
         this.useCache = "true".equals(screenElement.getAttribute("use-cache"));
@@ -67,6 +66,11 @@
             throw new IllegalArgumentException("No section found for the screen definition with name: " + this.name);
         }
         this.section = new ModelScreenWidget.Section(this, sectionElement);
+        this.section.isMainSection = true;
+    }
+    
+    public String getSourceLocation() {
+        return sourceLocation;
     }
 
     /**
@@ -93,9 +97,11 @@
         // make sure the "null" object is in there for entity ops
         context.put("null", GenericEntity.NULL_FIELD);
 
+        setWidgetBoundaryComments(context);
+
         // wrap the whole screen rendering in a transaction, should improve performance in querying and such
-        boolean beganTransaction = false;
         Map parameters = (Map) context.get("parameters");
+        boolean beganTransaction = false;
         int transactionTimeout = -1;
         if (parameters != null) {
             String transactionTimeoutPar = (String) parameters.get("TRANSACTION_TIMEOUT");
@@ -179,10 +185,6 @@
     public GenericDelegator getDelegator(Map context) {
         GenericDelegator delegator = (GenericDelegator) context.get("delegator");
         return delegator;
-    }
-    
-    public String getName() {
-        return name;
     }
 }
 

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenWidget.java Mon Nov 12 00:06:40 2007
@@ -40,6 +40,7 @@
 import org.ofbiz.base.util.UtilMisc;
 import org.ofbiz.base.util.collections.MapStack;
 import org.ofbiz.base.util.string.FlexibleStringExpander;
+import org.ofbiz.widget.ModelWidget;
 import org.ofbiz.widget.form.FormFactory;
 import org.ofbiz.widget.form.FormStringRenderer;
 import org.ofbiz.widget.form.ModelForm;
@@ -61,12 +62,13 @@
 /**
  * Widget Library - Screen model class
  */
-public abstract class ModelScreenWidget implements Serializable {
+public abstract class ModelScreenWidget extends ModelWidget implements Serializable {
     public static final String module = ModelScreenWidget.class.getName();
 
     protected ModelScreen modelScreen;
     
     public ModelScreenWidget(ModelScreen modelScreen, Element widgetElement) {
+        super(widgetElement);
         this.modelScreen = modelScreen;
         if (Debug.verboseOn()) Debug.logVerbose("Reading Screen sub-widget with name: " + widgetElement.getNodeName(), module);
     }
@@ -126,42 +128,17 @@
         Iterator subWidgetIter = subWidgets.iterator();
         while (subWidgetIter.hasNext()) {
             ModelScreenWidget subWidget = (ModelScreenWidget) subWidgetIter.next();
-            if (Debug.verboseOn()) Debug.logVerbose("Rendering screen " + subWidget.modelScreen.name + "; widget class is " + subWidget.getClass().getName(), module);
+            if (Debug.verboseOn()) Debug.logVerbose("Rendering screen " + subWidget.modelScreen.getName() + "; widget class is " + subWidget.getClass().getName(), module);
 
-            Map parameters = (Map) context.get("parameters");
-            boolean insertWidgetBoundaryComments = "true".equals(parameters==null?null:parameters.get("widgetVerbose"));
-            StringBuffer widgetDescription = null;
-            if (insertWidgetBoundaryComments) {
-                widgetDescription = new StringBuffer();
-                widgetDescription.append("Widget [screen:");
-                widgetDescription.append(subWidget.modelScreen.name);
-                widgetDescription.append("] ");
-                widgetDescription.append(subWidget.rawString());
-                
-                try {
-                    writer.write("<!-- === BEGIN ");
-                    writer.write(widgetDescription.toString());
-                    writer.write(" -->\n");
-                } catch (IOException e) {
-                    throw new GeneralException("Error adding verbose sub-widget HTML/XML comments:", e);
-                }
-            }
-            
             // render the sub-widget itself
             subWidget.renderWidgetString(writer, context, screenStringRenderer);
-            
-            if (insertWidgetBoundaryComments) {
-                try {
-                    writer.write("\n<!-- === END   ");
-                    writer.write(widgetDescription.toString());
-                    writer.write(" -->\n");
-                } catch (IOException e) {
-                    throw new GeneralException("Error adding verbose sub-widget HTML/XML comments:", e);
-                }
-            }
         }
     }
 
+    public boolean boundaryCommentsEnabled() {
+        return modelScreen.boundaryCommentsEnabled();
+    }
+    
     public static class SectionsRenderer {
         protected Map sectionMap;
         protected ScreenStringRenderer screenStringRenderer;
@@ -187,15 +164,14 @@
     }
 
     public static class Section extends ModelScreenWidget {
-        protected String name;
         protected ModelScreenCondition condition;
         protected List actions;
         protected List subWidgets;
         protected List failWidgets;
+        public boolean isMainSection = false;
         
         public Section(ModelScreen modelScreen, Element sectionElement) {
             super(modelScreen, sectionElement);
-            this.name = sectionElement.getAttribute("name");
 
             // read condition under the "condition" element
             Element conditionElement = UtilXml.firstChildElement(sectionElement, "condition");
@@ -221,7 +197,7 @@
                 this.failWidgets = ModelScreenWidget.readSubWidgets(this.modelScreen, failElementList);
             }
         }
-
+        
         public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException {
             // check the condition, if there is one
             boolean condTrue = true;
@@ -267,10 +243,14 @@
             
         }
         
-        public String getName() {
-            return name;
+        public String getBoundaryCommentName() {
+            if (isMainSection) {
+                return modelScreen.getSourceLocation() + "#" + modelScreen.getName();
+            } else {
+                return name;
+            }
         }
-
+        
         public String rawString() {
             return "<section" + (UtilValidate.isNotEmpty(this.name)?" name=\"" + this.name + "\"":"") + ">";
         }
@@ -505,12 +485,10 @@
     }
 
     public static class DecoratorSection extends ModelScreenWidget {
-        protected String name;
         protected List subWidgets;
         
         public DecoratorSection(ModelScreen modelScreen, Element decoratorSectionElement) {
             super(modelScreen, decoratorSectionElement);
-            this.name = decoratorSectionElement.getAttribute("name");
             // read sub-widgets
             List subElementList = UtilXml.childElementList(decoratorSectionElement);
             this.subWidgets = ModelScreenWidget.readSubWidgets(this.modelScreen, subElementList);
@@ -527,11 +505,9 @@
     }
     
     public static class DecoratorSectionInclude extends ModelScreenWidget {
-        protected String name;
         
         public DecoratorSectionInclude(ModelScreen modelScreen, Element decoratorSectionElement) {
             super(modelScreen, decoratorSectionElement);
-            this.name = decoratorSectionElement.getAttribute("name");
         }
 
         public void renderWidgetString(Writer writer, Map context, ScreenStringRenderer screenStringRenderer) throws GeneralException {

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java Mon Nov 12 00:06:40 2007
@@ -51,6 +51,7 @@
 import org.ofbiz.entity.model.ModelField;
 import org.ofbiz.entity.util.EntityListIterator;
 import org.ofbiz.service.LocalDispatcher;
+import org.ofbiz.widget.ModelWidget;
 import org.w3c.dom.Element;
 import org.xml.sax.SAXException;
 
@@ -59,11 +60,11 @@
 /**
  * Widget Library - Tree model class
  */
-public class ModelTree {
+public class ModelTree extends ModelWidget {
 
     public static final String module = ModelTree.class.getName();
 
-    protected String name;
+    protected String treeLocation;
     protected String rootNodeName;
     protected String defaultRenderStyle;
     protected FlexibleStringExpander defaultWrapStyleExdr;
@@ -89,8 +90,7 @@
     public ModelTree() {}
     
     public ModelTree(Element treeElement, GenericDelegator delegator, LocalDispatcher dispatcher) {
-
-        this.name = treeElement.getAttribute("name");
+        super(treeElement);
         this.rootNodeName = treeElement.getAttribute("root-node-name");
         this.defaultRenderStyle = UtilFormatOut.checkEmpty(treeElement.getAttribute("default-render-style"), "simple");
         // A temporary hack to accommodate those who might still be using "render-style" instead of "default-render-style"
@@ -134,10 +134,6 @@
 
     }
     
-    public String getName() {
-        return name;
-    }
-
     public void setDefaultEntityName(String name) {
         String nm = name;
         if (UtilValidate.isEmpty(nm)) {
@@ -213,7 +209,14 @@
         return currentNodeTrail;
     }
     
-
+    public String getBoundaryCommentName() {
+        return treeLocation + "#" + name;
+    }
+    
+    public void setTreeLocation(String treeLocation) {
+        this.treeLocation = treeLocation;
+    }
+    
     /**
      * Renders this tree to a String, i.e. in a text format, as defined with the
      * TreeStringRenderer implementation.
@@ -230,6 +233,9 @@
      *   use the same tree definitions for many types of tree UIs
      */
     public void renderTreeString(StringBuffer buf, Map context, TreeStringRenderer treeStringRenderer) throws GeneralException {
+        Map parameters = (Map) context.get("parameters");
+        setWidgetBoundaryComments(context);
+
         ModelNode node = (ModelNode)nodeMap.get(rootNodeName);
         /*
         List parentNodeTrail = (List)context.get("currentNodeTrail");
@@ -244,7 +250,6 @@
         String trailName = trailNameExdr.expandString(context);
         String treeString = (String)context.get(trailName);
         if (UtilValidate.isEmpty(treeString)) {
-            Map parameters = (Map)context.get("parameters");
             treeString = (String)parameters.get(trailName);
         }
         if (UtilValidate.isNotEmpty(treeString)) {

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java?rev=594042&r1=594041&r2=594042&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/TreeFactory.java Mon Nov 12 00:06:40 2007
@@ -65,7 +65,7 @@
                     URL treeFileUrl = null;
                     treeFileUrl = FlexibleLocation.resolveLocation(resourceName); //, loader);
                     Document treeFileDoc = UtilXml.readXmlDocument(treeFileUrl, true);
-                    modelTreeMap = readTreeDocument(treeFileDoc, delegator, dispatcher);
+                    modelTreeMap = readTreeDocument(treeFileDoc, delegator, dispatcher, resourceName);
                     treeLocationCache.put(resourceName, modelTreeMap);
                 }
             }
@@ -95,7 +95,7 @@
                     
                     URL treeFileUrl = servletContext.getResource(resourceName);
                     Document treeFileDoc = UtilXml.readXmlDocument(treeFileUrl, true);
-                    modelTreeMap = readTreeDocument(treeFileDoc, delegator, dispatcher);
+                    modelTreeMap = readTreeDocument(treeFileDoc, delegator, dispatcher, cacheKey);
                     treeWebappCache.put(cacheKey, modelTreeMap);
                 }
             }
@@ -108,7 +108,7 @@
         return modelTree;
     }
     
-    public static Map readTreeDocument(Document treeFileDoc, GenericDelegator delegator, LocalDispatcher dispatcher) {
+    public static Map readTreeDocument(Document treeFileDoc, GenericDelegator delegator, LocalDispatcher dispatcher, String treeLocation) {
         Map modelTreeMap = new HashMap();
         if (treeFileDoc != null) {
             // read document and construct ModelTree for each tree element
@@ -118,6 +118,7 @@
             while (treeElementIter.hasNext()) {
                 Element treeElement = (Element) treeElementIter.next();
                 ModelTree modelTree = new ModelTree(treeElement, delegator, dispatcher);
+                modelTree.setTreeLocation(treeLocation);
                 modelTreeMap.put(modelTree.getName(), modelTree);
             }
         }