Author: hansbak
Date: Thu Feb 12 07:26:16 2009 New Revision: 743639 URL: http://svn.apache.org/viewvc?rev=743639&view=rev Log: created a new attribute on the menu widget: portal-page. With this change the example component is now changed back to use the menu widget again however also serving the portal page buttons Modified: ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/ShowPortalPage.groovy ofbiz/trunk/framework/example/widget/example/CommonScreens.xml ofbiz/trunk/framework/example/widget/example/ExampleMenus.xml ofbiz/trunk/framework/widget/dtd/widget-menu.xsd ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenu.java ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java Modified: ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/ShowPortalPage.groovy URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/ShowPortalPage.groovy?rev=743639&r1=743638&r2=743639&view=diff ============================================================================== --- ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/ShowPortalPage.groovy (original) +++ ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/ShowPortalPage.groovy Thu Feb 12 07:26:16 2009 @@ -29,6 +29,9 @@ if (portalPageId) { portalPage = delegator.findByPrimaryKey("PortalPage", [portalPageId : portalPageId]); + if (portalPage.parentPortalPageId && !parameters.parentPortalPageId) { + parameters.parentPortalPageId = portalPage.parentPortalPageId; + } } if (!portalPage) { Modified: ofbiz/trunk/framework/example/widget/example/CommonScreens.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/CommonScreens.xml?rev=743639&r1=743638&r2=743639&view=diff ============================================================================== --- ofbiz/trunk/framework/example/widget/example/CommonScreens.xml (original) +++ ofbiz/trunk/framework/example/widget/example/CommonScreens.xml Thu Feb 12 07:26:16 2009 @@ -40,9 +40,9 @@ <set field="layoutSettings.companyName" from-field="uiLabelMap.ExampleCompanyName" global="true"/> <set field="layoutSettings.companySubtitle" from-field="uiLabelMap.ExampleCompanySubtitle" global="true"/> <set field="activeApp" value="example" global="true"/> - <!--set field="applicationMenuName" value="ExampleAppBar" global="true"/> - <set field="applicationMenuLocation" value="component://example/widget/example/ExampleMenus.xml" global="true"/--> - <set field="appheaderTemplate" value="component://example/webapp/appheader.ftl"/> + <set field="applicationMenuName" value="ExampleAppBar" global="true"/> + <set field="applicationMenuLocation" value="component://example/widget/example/ExampleMenus.xml" global="true"/> + <!--set field="appheaderTemplate" value="component://example/webapp/appheader.ftl"/--> <set field="parameters.parentPortalPageId" value="EXAMPLE"/> <script location="component://common/webcommon/WEB-INF/actions/includes/ListPortalPages.groovy"/> <set field="applicationTitle" value="${uiLabelMap.ExampleApplication}" global="true"/> Modified: ofbiz/trunk/framework/example/widget/example/ExampleMenus.xml URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/example/widget/example/ExampleMenus.xml?rev=743639&r1=743638&r2=743639&view=diff ============================================================================== --- ofbiz/trunk/framework/example/widget/example/ExampleMenus.xml (original) +++ ofbiz/trunk/framework/example/widget/example/ExampleMenus.xml Thu Feb 12 07:26:16 2009 @@ -21,13 +21,14 @@ <menus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-menu.xsd"> - <!--menu name="ExampleAppBar" title="${uiLabelMap.ExampleApplication}" extends="CommonAppBarMenu" extends-resource="component://common/widget/CommonMenus.xml"> + <menu name="ExampleAppBar" title="${uiLabelMap.ExampleApplication}" extends="CommonAppBarMenu" extends-resource="component://common/widget/CommonMenus.xml"> <menu-item name="Example" title="${uiLabelMap.ExampleExample}"><link target="FindExample"/></menu-item> <menu-item name="ExampleFeature" title="${uiLabelMap.ExampleFeature}"><link target="FindExampleFeature"/></menu-item> <menu-item name="FormWidgetExamples" title="${uiLabelMap.ExampleFormWidgetExamples}"><link target="FormWidgetExamples"/></menu-item> <menu-item name="AjaxExample" title="Ajax Examples"><link target="authview/findExampleAjax"/></menu-item> + <menu-item portal-page="EXAMPLE"/> <menu-item name="Dashboard" title="Dashboard" align-style="opposed"><link target="ManagePortalPages?portalPageId=${currentPortalPage.portalPageId}"/></menu-item> - </menu--> + </menu> <menu name="EditExample" default-selected-style="selected" type="simple" menu-container-style="button-bar tab-bar" selected-menuitem-context-field-name="tabButtonItem"> Modified: ofbiz/trunk/framework/widget/dtd/widget-menu.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-menu.xsd?rev=743639&r1=743638&r2=743639&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-menu.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-menu.xsd Thu Feb 12 07:26:16 2009 @@ -45,6 +45,7 @@ </xs:simpleType> </xs:attribute> <xs:attribute type="xs:string" name="id"/> + <xs:attribute type="xs:string" name="portal-page"/> <xs:attribute type="xs:string" name="title"/> <xs:attribute type="xs:string" name="tooltip"/> <xs:attribute type="xs:string" name="default-entity-name"/> 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=743639&r1=743638&r2=743639&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 Thu Feb 12 07:26:16 2009 @@ -26,13 +26,19 @@ import org.ofbiz.base.util.BshUtil; import org.ofbiz.base.util.Debug; +import org.ofbiz.base.util.UtilMisc; import org.ofbiz.base.util.UtilValidate; import org.ofbiz.base.util.UtilXml; import org.ofbiz.base.util.collections.FlexibleMapAccessor; import org.ofbiz.base.util.string.FlexibleStringExpander; import org.ofbiz.entity.GenericDelegator; +import org.ofbiz.entity.GenericEntityException; +import org.ofbiz.entity.GenericValue; +import org.ofbiz.entity.condition.EntityCondition; +import org.ofbiz.entity.condition.EntityOperator; import org.ofbiz.service.LocalDispatcher; import org.ofbiz.widget.ModelWidget; +import org.ofbiz.widget.menu.ModelMenuItem.Link; import org.w3c.dom.Element; import bsh.EvalError; @@ -244,11 +250,34 @@ } } - // read in add item defs, add/override one by one using the menuItemList and menuItemMap + // read in add item defs, add/override one by one using the menuItemList and menuItemMap and add portal pages List<? extends Element> itemElements = UtilXml.childElementList(menuElement, "menu-item"); for (Element itemElement : itemElements) { - ModelMenuItem modelMenuItem = new ModelMenuItem(itemElement, this); - modelMenuItem = this.addUpdateMenuItem(modelMenuItem); + String portalResource = itemElement.getAttribute("portal-page"); + if (UtilValidate.isNotEmpty(portalResource)) { + ModelMenuItem modelMenuItem = new ModelMenuItem(itemElement, this); + List <GenericValue> portalPages = null; + List exprs = UtilMisc.toList(EntityCondition.makeCondition("portalPageId", EntityOperator.EQUALS, portalResource), + EntityCondition.makeCondition("parentPortalPageId", EntityOperator.EQUALS, portalResource)); + EntityCondition cond = EntityCondition.makeCondition(exprs, EntityOperator.OR); + try { + portalPages = delegator.findList("PortalPage", cond, null, UtilMisc.toList("sequenceNum"), null, false); + } catch (GenericEntityException e) { + Debug.logError("Could not retrieve portalpages in the menu:" + e.getMessage(), module); + } + for (GenericValue portalPage : portalPages) { + if (UtilValidate.isNotEmpty(portalPage.getString("portalPageName"))) { + modelMenuItem.setName(portalPage.getString("portalPageName")); + modelMenuItem.setTitle(portalPage.getString("portalPageName")); + modelMenuItem.link = new Link(itemElement, modelMenuItem); + modelMenuItem.link.setTarget("showPortalPage?portalPageId=" + portalPage.getString("portalPageId")); + modelMenuItem = this.addUpdateMenuItem(modelMenuItem); + } + } + } else { + ModelMenuItem modelMenuItem = new ModelMenuItem(itemElement, this); + modelMenuItem = this.addUpdateMenuItem(modelMenuItem); + } } } /** @@ -340,7 +369,6 @@ for (ModelMenuItem item : this.menuItemList) { item.renderMenuItemString(writer, context, menuStringRenderer); } - // render formatting wrapper close menuStringRenderer.renderFormatSimpleWrapperClose(writer, context, this); Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java?rev=743639&r1=743638&r2=743639&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/menu/ModelMenuItem.java Thu Feb 12 07:26:16 2009 @@ -544,6 +544,11 @@ } + // create link only for portal page + public Link(ModelMenuItem parentMenuItem) { + this.linkMenuItem = parentMenuItem; + } + public void renderLinkString(Appendable writer, Map<String, Object> context, MenuStringRenderer menuStringRenderer) throws IOException { menuStringRenderer.renderLink(writer, context, this); } |
Free forum by Nabble | Edit this page |