Author: jleroux
Date: Sat Dec 28 18:55:53 2013 New Revision: 1553887 URL: http://svn.apache.org/r1553887 Log: A patch from Leon for "NPE thrown out while rendering disabled menu item" https://issues.apache.org/jira/browse/OFBIZ-5451 The method "renderLink" of new class MacroMenuRenderer calls the WidgetWorker.determineAutoLinkType. When menuItem.getDisabled() is true, the link target will be set to null and NPE occurs. jleroux: This was related with r1517353 and r1537833. The Leon's patch fixes r1517353 and this commits also reverts r1537833 Modified: ofbiz/trunk/applications/order/widget/ordermgr/OrderMenus.xml ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MacroMenuRenderer.java ofbiz/trunk/framework/widget/templates/htmlMenuMacroLibrary.ftl Modified: ofbiz/trunk/applications/order/widget/ordermgr/OrderMenus.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/order/widget/ordermgr/OrderMenus.xml?rev=1553887&r1=1553886&r2=1553887&view=diff ============================================================================== --- ofbiz/trunk/applications/order/widget/ordermgr/OrderMenus.xml (original) +++ ofbiz/trunk/applications/order/widget/ordermgr/OrderMenus.xml Sat Dec 28 18:55:53 2013 @@ -262,7 +262,7 @@ under the License. <link target="EditQuote"/> </menu-item> <menu-item name="createOrder" title="${uiLabelMap.OrderCreateOrder}"> - <condition> + <condition disabled-style="disabled"> <and> <not><if-empty field="quote"/></not> <if-compare operator="equals" value="QUO_APPROVED" field="quote.statusId"/> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MacroMenuRenderer.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MacroMenuRenderer.java?rev=1553887&r1=1553886&r2=1553887&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MacroMenuRenderer.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/MacroMenuRenderer.java Sat Dec 28 18:55:53 2013 @@ -203,7 +203,10 @@ public class MacroMenuRenderer implement parameters.put("targetWindow", link.getTargetWindow(context)); String uniqueItemName = menuItem.getModelMenu().getName() + "_" + menuItem.getName() + "_LF_" + UtilMisc.<String> addToBigDecimalInMap(context, "menuUniqueItemIndex", BigDecimal.ONE); parameters.put("uniqueItemName", uniqueItemName); - String linkType = WidgetWorker.determineAutoLinkType(link.getLinkType(), target, link.getUrlMode(), request); + String linkType = ""; + if (UtilValidate.isNotEmpty(target)) { + linkType = WidgetWorker.determineAutoLinkType(link.getLinkType(), target, link.getUrlMode(), request); + } parameters.put("linkType", linkType); String linkUrl = ""; String actionUrl = ""; Modified: ofbiz/trunk/framework/widget/templates/htmlMenuMacroLibrary.ftl URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/templates/htmlMenuMacroLibrary.ftl?rev=1553887&r1=1553886&r2=1553887&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/templates/htmlMenuMacroLibrary.ftl (original) +++ ofbiz/trunk/framework/widget/templates/htmlMenuMacroLibrary.ftl Sat Dec 28 18:55:53 2013 @@ -47,14 +47,18 @@ under the License. </#macro> <#macro renderLink linkUrl parameterList targetWindow uniqueItemName actionUrl linkType="" id="" style="" name="" height="" width="" text="" imgStr=""> - <#if "hidden-form" == linkType> + <#if linkType?has_content && "hidden-form" == linkType> <form method="post" action="${actionUrl}"<#if targetWindow?has_content> target="${targetWindow}"</#if> onsubmit="javascript:submitFormDisableSubmits(this)" name="${uniqueItemName}"><#rt/> <#list parameterList as parameter> <input name="${parameter.name}" value="${parameter.value}" type="hidden"/><#rt/> </#list> </form><#rt/> </#if> -<a<#if id?has_content> id="${id}"</#if><#if style?has_content> class="${style}"</#if><#if name?has_content> name="${name}"</#if><#if targetWindow?has_content> target="${targetWindow}"</#if> href="<#if "hidden-form"==linkType>javascript:document.${uniqueItemName}.submit()<#else>${linkUrl}</#if>"><#if imgStr?has_content>${imgStr}</#if><#if text?has_content>${text}</#if></a><#rt/> +<#if linkType?has_content> +<a<#if id?has_content> id="${id}"</#if><#if style?has_content> class="${style}"</#if><#if name?has_content> name="${name}"</#if><#if targetWindow?has_content> target="${targetWindow}"</#if> href="<#if "hidden-form"==linkType>javascript:document.${uniqueItemName}.submit()<#else>${linkUrl}</#if>"><#rt/> +</#if> +<#if imgStr?has_content>${imgStr}</#if><#if text?has_content>${text}</#if><#rt/> +<#if linkType?has_content></a><#rt/></#if> </#macro> <#macro renderMenuItemBegin style toolTip linkStr containsNestedMenus> |
Free forum by Nabble | Edit this page |