Author: jacopoc
Date: Wed Mar 10 15:21:23 2010 New Revision: 921397 URL: http://svn.apache.org/viewvc?rev=921397&view=rev Log: Reverted rev. 920359 (by erwan) and reimplemented in a cleaner way by refactoring the renderHyperlinkTitle code. Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/MacroFormRenderer.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl 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=921397&r1=921396&r2=921397&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 Mar 10 15:21:23 2010 @@ -95,7 +95,6 @@ public class MacroFormRenderer implement protected HttpServletResponse response; protected boolean javaScriptEnabled = false; protected boolean renderPagination = true; - protected String contentType; public MacroFormRenderer(String macroLibraryPath, Appendable writer, HttpServletRequest request, HttpServletResponse response) throws TemplateException, IOException { macroLibrary = FreeMarkerWorker.getTemplate(macroLibraryPath); @@ -109,11 +108,6 @@ public class MacroFormRenderer implement internalEncoder = StringUtil.getEncoder("string"); } - public MacroFormRenderer(String macroLibraryPath, Appendable writer, HttpServletRequest request, HttpServletResponse response, String contentType) throws TemplateException, IOException { - this(macroLibraryPath, writer, request, response); - this.contentType = contentType; - } - public boolean getRenderPagination() { return this.renderPagination; } @@ -1150,26 +1144,61 @@ public class MacroFormRenderer implement sb.append(" "); } else { titleText = encode(titleText, modelFormField, context); - renderHyperlinkTitle(sb, context, modelFormField, titleText); + if (UtilValidate.isNotEmpty(modelFormField.getHeaderLink())) { + StringBuilder targetBuffer = new StringBuilder(); + FlexibleStringExpander target = FlexibleStringExpander.getInstance(modelFormField.getHeaderLink()); + String fullTarget = target.expandString(context); + targetBuffer.append(fullTarget); + String targetType = HyperlinkField.DEFAULT_TARGET_TYPE; + if (UtilValidate.isNotEmpty(targetBuffer.toString()) && targetBuffer.toString().toLowerCase().startsWith("javascript:")) { + targetType="plain"; + } + StringWriter sr = new StringWriter(); + makeHyperlinkString(sr, modelFormField.getHeaderLinkStyle(), targetType, targetBuffer.toString(), null, titleText, "", modelFormField, this.request, this.response, context, ""); + + String title = sr.toString().replace("\"", "\'"); + sr = new StringWriter(); + sr.append("<@renderHyperlinkTitle "); + sr.append(" name=\""); + sr.append(modelFormField.getModelForm().getName()); + sr.append("\" title=\""); + sr.append(title); + sr.append("\" />"); + executeMacro(sr.toString()); + } else if (modelFormField.isSortField()) { + renderSortField(writer, context, modelFormField, titleText); + } else if (modelFormField.isRowSubmit()) { + StringWriter sr = new StringWriter(); + sr.append("<@renderHyperlinkTitle "); + sr.append(" name=\""); + sr.append(modelFormField.getModelForm().getName()); + sr.append("\" title=\""); + sr.append(titleText); + sr.append("\" showSelectAll=\"Y\"/>"); + executeMacro(sr.toString()); + } else { + sb.append(titleText); + } } } - //check for required field style on single forms - if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) { - String requiredStyle = modelFormField.getRequiredFieldStyle(); - if (UtilValidate.isNotEmpty(requiredStyle)) { - style = requiredStyle; + if (!sb.toString().isEmpty()) { + //check for required field style on single forms + if ("single".equals(modelFormField.getModelForm().getType()) && modelFormField.getRequiredField()) { + String requiredStyle = modelFormField.getRequiredFieldStyle(); + if (UtilValidate.isNotEmpty(requiredStyle)) { + style = requiredStyle; + } } + StringWriter sr = new StringWriter(); + sr.append("<@renderFieldTitle "); + sr.append(" style=\""); + sr.append(style); + sr.append("\" title=\""); + sr.append(sb.toString()); + sr.append("\" />"); + executeMacro(sr.toString()); } - - StringWriter sr = new StringWriter(); - sr.append("<@renderFieldTitle "); - sr.append(" style=\""); - sr.append(style); - sr.append("\" title=\""); - sr.append(sb.toString()); - sr.append("\" />"); - executeMacro(sr.toString()); } public void renderSingleFormFieldTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField) throws IOException { @@ -2597,43 +2626,6 @@ public class MacroFormRenderer implement executeMacro(sr.toString()); } } - public void renderHyperlinkTitle(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException { - if (UtilValidate.isNotEmpty(modelFormField.getHeaderLink())) { - StringBuilder targetBuffer = new StringBuilder(); - FlexibleStringExpander target = FlexibleStringExpander.getInstance(modelFormField.getHeaderLink()); - String fullTarget = target.expandString(context); - targetBuffer.append(fullTarget); - String targetType = HyperlinkField.DEFAULT_TARGET_TYPE; - if (UtilValidate.isNotEmpty(targetBuffer.toString()) && targetBuffer.toString().toLowerCase().startsWith("javascript:")) { - targetType="plain"; - } - StringWriter sr = new StringWriter(); - makeHyperlinkString(sr, modelFormField.getHeaderLinkStyle(), targetType, targetBuffer.toString(), null, titleText, "", modelFormField, this.request, this.response, context, ""); - - String title = sr.toString().replace("\"", "\'"); - sr = new StringWriter(); - sr.append("<@renderHyperlinkTitle "); - sr.append(" name=\""); - sr.append(modelFormField.getModelForm().getName()); - sr.append("\" title=\""); - sr.append(title); - sr.append("\" />"); - executeMacro(sr.toString()); - } else if (modelFormField.isSortField() && !"text/csv".equals(this.getContentType()) && !"application/pdf".equals(this.getContentType())) { - renderSortField (writer, context, modelFormField, titleText); - } else if (modelFormField.isRowSubmit()) { - StringWriter sr = new StringWriter(); - sr.append("<@renderHyperlinkTitle "); - sr.append(" name=\""); - sr.append(modelFormField.getModelForm().getName()); - sr.append("\" title=\""); - sr.append(titleText); - sr.append("\" showSelectAll=\"Y\"/>"); - executeMacro(sr.toString()); - } else { - writer.append(titleText); - } - } public void renderSortField(Appendable writer, Map<String, Object> context, ModelFormField modelFormField, String titleText) throws IOException { boolean ajaxEnabled = false; @@ -2971,12 +2963,4 @@ public class MacroFormRenderer implement sr.append("\" />"); executeMacro(sr.toString()); } - - public void setContentType(String contentType){ - this.contentType = contentType; - } - - public String getContentType(){ - return this.contentType; - } } Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java?rev=921397&r1=921396&r2=921397&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/MacroScreenViewHandler.java Wed Mar 10 15:21:23 2010 @@ -88,7 +88,7 @@ public class MacroScreenViewHandler exte } ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(UtilProperties.getPropertyValue("widget", getName() + ".name"), UtilProperties.getPropertyValue("widget", getName() + ".screenrenderer"), writer); - FormStringRenderer formStringRenderer = new MacroFormRenderer(UtilProperties.getPropertyValue("widget", getName() + ".formrenderer"), writer, request, response, contentType); + FormStringRenderer formStringRenderer = new MacroFormRenderer(UtilProperties.getPropertyValue("widget", getName() + ".formrenderer"), writer, request, response); TreeStringRenderer treeStringRenderer = new MacroTreeRenderer(UtilProperties.getPropertyValue("widget", getName() + ".treerenderer"), writer); // TODO: uncomment these lines when the renderers are implemented //MenuStringRenderer menuStringRenderer = new MacroMenuRenderer(UtilProperties.getPropertyValue("widget", getName() + ".menurenderer"), writer); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java?rev=921397&r1=921396&r2=921397&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ScreenFopViewHandler.java Wed Mar 10 15:21:23 2010 @@ -68,7 +68,7 @@ public class ScreenFopViewHandler extend Writer writer = new StringWriter(); try { ScreenStringRenderer screenStringRenderer = new MacroScreenRenderer(UtilProperties.getPropertyValue("widget", getName() + ".name"), UtilProperties.getPropertyValue("widget", getName() + ".screenrenderer"), writer); - FormStringRenderer formStringRenderer = new MacroFormRenderer(UtilProperties.getPropertyValue("widget", getName() + ".formrenderer"), writer, request, response, contentType); + FormStringRenderer formStringRenderer = new MacroFormRenderer(UtilProperties.getPropertyValue("widget", getName() + ".formrenderer"), writer, request, response); // TODO: uncomment these lines when the renderers are implemented //TreeStringRenderer treeStringRenderer = new MacroTreeRenderer(UtilProperties.getPropertyValue("widget", getName() + ".treerenderer"), writer); //MenuStringRenderer menuStringRenderer = new MacroMenuRenderer(UtilProperties.getPropertyValue("widget", getName() + ".menurenderer"), writer); Modified: ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl?rev=921397&r1=921396&r2=921397&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl (original) +++ ofbiz/trunk/framework/widget/templates/csvFormMacroLibrary.ftl Wed Mar 10 15:21:23 2010 @@ -113,7 +113,7 @@ under the License. <#macro renderFieldGroupClose style id title></#macro> <#macro renderHyperlinkTitle name title showSelectAll="N"></#macro> -<#macro renderSortField style title linkUrl ajaxEnabled></#macro> +<#macro renderSortField style title linkUrl ajaxEnabled><@renderFieldTitle style title /></#macro> <#macro formatBoundaryComment boundaryType widgetType widgetName></#macro> <#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description><@renderField description /></#macro> <#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc linkUrl targetWindow description confirmation><@renderField description /></#macro> Modified: ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl?rev=921397&r1=921396&r2=921397&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl (original) +++ ofbiz/trunk/framework/widget/templates/foFormMacroLibrary.ftl Wed Mar 10 15:21:23 2010 @@ -132,7 +132,7 @@ under the License. <#macro renderFieldGroupClose style id title></#macro> <#macro renderHyperlinkTitle name title showSelectAll="N"></#macro> -<#macro renderSortField style title linkUrl ajaxEnabled></#macro> +<#macro renderSortField style title linkUrl ajaxEnabled><@renderFieldTitle style title /></#macro> <#macro formatBoundaryComment boundaryType widgetType widgetName></#macro> <#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description><@renderField description /></#macro> <#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc linkUrl targetWindow description confirmation><@makeBlock linkStyle description /></#macro> Modified: ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl?rev=921397&r1=921396&r2=921397&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl (original) +++ ofbiz/trunk/framework/widget/templates/textFormMacroLibrary.ftl Wed Mar 10 15:21:23 2010 @@ -113,7 +113,7 @@ under the License. <#macro renderFieldGroupClose style id title></#macro> <#macro renderHyperlinkTitle name title showSelectAll="N"></#macro> -<#macro renderSortField style title linkUrl ajaxEnabled></#macro> +<#macro renderSortField style title linkUrl ajaxEnabled><@renderFieldTitle style title /></#macro> <#macro formatBoundaryComment boundaryType widgetType widgetName></#macro> <#macro makeHiddenFormLinkAnchor linkStyle hiddenFormName event action imgSrc description><@renderField description /></#macro> <#macro makeHyperlinkString linkStyle hiddenFormName event action imgSrc linkUrl targetWindow description><@renderField description /></#macro> \ No newline at end of file |
Free forum by Nabble | Edit this page |