Author: adrianc
Date: Wed May 19 21:57:18 2010 New Revision: 946431 URL: http://svn.apache.org/viewvc?rev=946431&view=rev Log: Updated model widgets to eliminate calls to methods deprecated in previous commit. Widget comment state is stored in the renderer, not in the model. All widget comments work properly now. Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.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/html/HtmlWidgetRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.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/MacroTreeRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/ModelTree.java Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java?rev=946431&r1=946430&r2=946431&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoFormRenderer.java Wed May 19 21:57:18 2010 @@ -27,6 +27,7 @@ import javax.servlet.http.HttpServletRes import org.ofbiz.base.util.UtilFormatOut; import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.widget.ModelWidget; import org.ofbiz.widget.WidgetWorker; import org.ofbiz.widget.form.FormStringRenderer; import org.ofbiz.widget.form.ModelForm; @@ -179,6 +180,7 @@ public class FoFormRenderer extends Html } public void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context); renderBeginningBoundaryComment(writer, "Form Widget", modelForm); } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java?rev=946431&r1=946430&r2=946431&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/fo/FoScreenRenderer.java Wed May 19 21:57:18 2010 @@ -24,6 +24,7 @@ import java.util.Map; import org.ofbiz.base.util.GeneralException; import org.ofbiz.base.util.UtilProperties; import org.ofbiz.base.util.UtilValidate; +import org.ofbiz.widget.ModelWidget; import org.ofbiz.widget.html.HtmlWidgetRenderer; import org.ofbiz.widget.screen.ModelScreenWidget; import org.ofbiz.widget.screen.ScreenStringRenderer; @@ -58,6 +59,9 @@ public class FoScreenRenderer extends Ht } public void renderSectionBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.Section section) throws IOException { + if (section.isMainSection) { + this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context); + } renderBeginningBoundaryComment(writer, section.isMainSection?"Screen":"Section Widget", section); } public void renderSectionEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.Section section) throws IOException { Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java?rev=946431&r1=946430&r2=946431&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java Wed May 19 21:57:18 2010 @@ -98,6 +98,7 @@ public class MacroFormRenderer implement protected HttpServletResponse response; protected boolean javaScriptEnabled = false; protected boolean renderPagination = true; + protected boolean widgetCommentsEnabled = false; public MacroFormRenderer(String macroLibraryPath, HttpServletRequest request, HttpServletResponse response) throws TemplateException, IOException { macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath); @@ -1232,6 +1233,7 @@ public class MacroFormRenderer implement } public void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context); renderBeginningBoundaryComment(writer, "Form Widget - Form Element", modelForm); String targetType = modelForm.getTargetType(); String targ = modelForm.getTarget(context, targetType); @@ -2639,7 +2641,7 @@ public class MacroFormRenderer implement * @param modelWidget The widget */ public void renderBeginningBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget) throws IOException { - if (modelWidget.boundaryCommentsEnabled()) { + if (this.widgetCommentsEnabled) { StringWriter sr = new StringWriter(); sr.append("<@formatBoundaryComment "); sr.append(" boundaryType=\""); @@ -2660,7 +2662,7 @@ public class MacroFormRenderer implement * @param modelWidget The widget */ public void renderEndingBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget) throws IOException { - if (modelWidget.boundaryCommentsEnabled()) { + if (this.widgetCommentsEnabled) { StringWriter sr = new StringWriter(); sr.append("<@formatBoundaryComment "); sr.append(" boundaryType=\""); 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=946431&r1=946430&r2=946431&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 Wed May 19 21:57:18 2010 @@ -809,8 +809,6 @@ public class ModelForm extends ModelWidg runFormActions(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); 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=946431&r1=946430&r2=946431&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 Wed May 19 21:57:18 2010 @@ -43,6 +43,7 @@ import org.ofbiz.base.util.StringUtil.Si import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.webapp.control.RequestHandler; import org.ofbiz.webapp.taglib.ContentUrlTag; +import org.ofbiz.widget.ModelWidget; import org.ofbiz.widget.WidgetWorker; import org.ofbiz.widget.form.FormStringRenderer; import org.ofbiz.widget.form.ModelForm; @@ -1308,6 +1309,7 @@ public class HtmlFormRenderer extends Ht * @see org.ofbiz.widget.form.FormStringRenderer#renderFormOpen(java.io.Writer, java.util.Map, org.ofbiz.widget.form.ModelForm) */ public void renderFormOpen(Appendable writer, Map<String, Object> context, ModelForm modelForm) throws IOException { + this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context); renderBeginningBoundaryComment(writer, "Form Widget - Form Element", modelForm); writer.append("<form method=\"post\" "); String targetType = modelForm.getTargetType(); @@ -1438,6 +1440,7 @@ public class HtmlFormRenderer extends Ht String queryString = UtilHttp.urlEncodeArgs(inputFields); context.put("_QBESTRING_", queryString); + this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context); renderBeginningBoundaryComment(writer, "Form Widget", modelForm); if (this.renderPagination) { 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=946431&r1=946430&r2=946431&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 Wed May 19 21:57:18 2010 @@ -35,6 +35,7 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.entity.GenericValue; import org.ofbiz.webapp.control.RequestHandler; import org.ofbiz.webapp.taglib.ContentUrlTag; +import org.ofbiz.widget.ModelWidget; import org.ofbiz.widget.WidgetWorker; import org.ofbiz.widget.menu.MenuStringRenderer; import org.ofbiz.widget.menu.ModelMenu; @@ -238,6 +239,7 @@ public class HtmlMenuRenderer extends Ht } //Debug.logInfo("in HtmlMenuRenderer, userLoginIdHasChanged:" + userLoginIdHasChanged,""); + this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context); renderBeginningBoundaryComment(writer, "Menu Widget", modelMenu); writer.append("<div"); String menuId = modelMenu.getId(); 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=946431&r1=946430&r2=946431&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 Wed May 19 21:57:18 2010 @@ -42,6 +42,7 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.webapp.control.RequestHandler; import org.ofbiz.webapp.taglib.ContentUrlTag; +import org.ofbiz.widget.ModelWidget; import org.ofbiz.widget.WidgetContentWorker; import org.ofbiz.widget.WidgetDataResourceWorker; import org.ofbiz.widget.WidgetWorker; @@ -80,6 +81,9 @@ public class HtmlScreenRenderer extends } public void renderSectionBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.Section section) throws IOException { + if (section.isMainSection) { + this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context); + } renderBeginningBoundaryComment(writer, section.isMainSection?"Screen":"Section Widget", section); } 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=946431&r1=946430&r2=946431&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 Wed May 19 21:57:18 2010 @@ -31,6 +31,7 @@ import org.ofbiz.base.util.UtilGenerics; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.webapp.control.RequestHandler; import org.ofbiz.webapp.taglib.ContentUrlTag; +import org.ofbiz.widget.ModelWidget; import org.ofbiz.widget.WidgetWorker; import org.ofbiz.widget.screen.ScreenRenderer; import org.ofbiz.widget.screen.ScreenStringRenderer; @@ -53,6 +54,7 @@ public class HtmlTreeRenderer extends Ht List<String> currentNodeTrail = UtilGenerics.toList(context.get("currentNodeTrail")); if (node.isRootNode()) { appendWhitespace(writer); + this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context); renderBeginningBoundaryComment(writer, "Tree Widget", node.getModelTree()); writer.append("<ul class=\"basic-tree\">"); } Modified: 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=946431&r1=946430&r2=946431&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlWidgetRenderer.java Wed May 19 21:57:18 2010 @@ -36,6 +36,8 @@ public class HtmlWidgetRenderer { */ public static final String whiteSpace = "\r\n"; + protected boolean widgetCommentsEnabled = false; + /** * Helper method used to append whitespace characters to the end of each rendered element. * @param writer The writer to write to @@ -65,7 +67,7 @@ public class HtmlWidgetRenderer { * @param modelWidget The widget */ public void renderBeginningBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget) throws IOException { - if (modelWidget.boundaryCommentsEnabled()) { + if (this.widgetCommentsEnabled) { writer.append(this.buildBoundaryComment("Begin", widgetType, modelWidget.getBoundaryCommentName())); } } @@ -77,7 +79,7 @@ public class HtmlWidgetRenderer { * @param modelWidget The widget */ public void renderEndingBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget) throws IOException { - if (modelWidget.boundaryCommentsEnabled()) { + if (this.widgetCommentsEnabled) { writer.append(this.buildBoundaryComment("End", widgetType, modelWidget.getBoundaryCommentName())); } } 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=946431&r1=946430&r2=946431&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 Wed May 19 21:57:18 2010 @@ -307,7 +307,6 @@ public class ModelMenu extends ModelWidg * use the same menu definitions for many types of menu UIs */ public void renderMenuString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer) throws IOException { - setWidgetBoundaryComments(context); boolean passed = true; Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java?rev=946431&r1=946430&r2=946431&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenRenderer.java Wed May 19 21:57:18 2010 @@ -47,6 +47,7 @@ import org.ofbiz.entity.Delegator; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.webapp.control.RequestHandler; import org.ofbiz.webapp.taglib.ContentUrlTag; +import org.ofbiz.widget.ModelWidget; import org.ofbiz.widget.WidgetContentWorker; import org.ofbiz.widget.WidgetDataResourceWorker; import org.ofbiz.widget.WidgetWorker; @@ -69,6 +70,7 @@ public class MacroScreenRenderer impleme private WeakHashMap<Appendable, Environment> environments = new WeakHashMap<Appendable, Environment>(); private String rendererName; private int elementId = 999; + protected boolean widgetCommentsEnabled = false; public MacroScreenRenderer(String name, String macroLibraryPath) throws TemplateException, IOException { macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath); @@ -123,7 +125,10 @@ public class MacroScreenRenderer impleme } public void renderSectionBegin(Appendable writer, Map<String, Object> context, ModelScreenWidget.Section section) throws IOException { - if (section.boundaryCommentsEnabled()) { + if (section.isMainSection) { + this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context); + } + if (this.widgetCommentsEnabled) { StringWriter sr = new StringWriter(); sr.append("<@renderSectionBegin "); sr.append("boundaryComment=\"Begin "); @@ -134,7 +139,7 @@ public class MacroScreenRenderer impleme } } public void renderSectionEnd(Appendable writer, Map<String, Object> context, ModelScreenWidget.Section section) throws IOException { - if (section.boundaryCommentsEnabled()) { + if (this.widgetCommentsEnabled) { StringWriter sr = new StringWriter(); sr.append("<@renderSectionEnd "); sr.append("boundaryComment=\"End "); 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=946431&r1=946430&r2=946431&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 Wed May 19 21:57:18 2010 @@ -349,8 +349,6 @@ public class ModelScreen extends ModelWi // 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 Map<String, String> parameters = UtilGenerics.cast(context.get("parameters")); boolean beganTransaction = false; 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=946431&r1=946430&r2=946431&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 Wed May 19 21:57:18 2010 @@ -101,11 +101,6 @@ public abstract class ModelScreenWidget } } - @Override - public boolean boundaryCommentsEnabled() { - return modelScreen.boundaryCommentsEnabled(); - } - public ModelScreen getModelScreen() { return this.modelScreen; } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/MacroTreeRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/MacroTreeRenderer.java?rev=946431&r1=946430&r2=946431&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/MacroTreeRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/tree/MacroTreeRenderer.java Wed May 19 21:57:18 2010 @@ -58,6 +58,8 @@ public class MacroTreeRenderer implement ScreenStringRenderer screenStringRenderer = null; private Template macroLibrary; private Environment environment; + protected boolean widgetCommentsEnabled = false; + public MacroTreeRenderer(String macroLibraryPath, Appendable writer) throws TemplateException, IOException { this.macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath); @@ -96,7 +98,7 @@ public class MacroTreeRenderer implement * @param modelWidget The widget */ public void renderBeginningBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget) throws IOException { - if (modelWidget.boundaryCommentsEnabled()) { + if (this.widgetCommentsEnabled) { StringWriter sr = new StringWriter(); sr.append("<@formatBoundaryComment "); sr.append(" boundaryType=\""); @@ -117,7 +119,7 @@ public class MacroTreeRenderer implement * @param modelWidget The widget */ public void renderEndingBoundaryComment(Appendable writer, String widgetType, ModelWidget modelWidget) throws IOException { - if (modelWidget.boundaryCommentsEnabled()) { + if (this.widgetCommentsEnabled) { StringWriter sr = new StringWriter(); sr.append("<@formatBoundaryComment "); sr.append(" boundaryType=\""); @@ -137,6 +139,7 @@ public class MacroTreeRenderer implement String style = ""; if (node.isRootNode()) { + this.widgetCommentsEnabled = ModelWidget.widgetBoundaryCommentsEnabled(context); renderBeginningBoundaryComment(writer, "Tree Widget", node.getModelTree()); style = "basic-tree"; } 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=946431&r1=946430&r2=946431&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 Wed May 19 21:57:18 2010 @@ -229,7 +229,6 @@ public class ModelTree extends ModelWidg */ public void renderTreeString(StringBuffer buf, Map<String, Object> context, TreeStringRenderer treeStringRenderer) throws GeneralException { Map<String, Object> parameters = UtilGenerics.checkMap(context.get("parameters")); - setWidgetBoundaryComments(context); ModelNode node = (ModelNode)nodeMap.get(rootNodeName); |
Free forum by Nabble | Edit this page |