|
Author: buscob
Date: Mon Nov 30 08:29:28 2009 New Revision: 885346 URL: http://svn.apache.org/viewvc?rev=885346&view=rev Log: Added new ScreenCondition "if-empty-section". This can be used in a Decorator to check if a decorator-section has been defined and added content to in the decorated screens. Modified: ofbiz/trunk/framework/widget/dtd/widget-screen.xsd ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java Modified: ofbiz/trunk/framework/widget/dtd/widget-screen.xsd URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-screen.xsd?rev=885346&r1=885345&r2=885346&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/dtd/widget-screen.xsd (original) +++ ofbiz/trunk/framework/widget/dtd/widget-screen.xsd Mon Nov 30 08:29:28 2009 @@ -299,6 +299,14 @@ <xs:attributeGroup name="attlist.if-empty"> <xs:attribute type="xs:string" name="field" use="required"/> </xs:attributeGroup> + <xs:element name="if-empty-section" substitutionGroup="AllConditionals"> + <xs:complexType> + <xs:attributeGroup ref="attlist.if-empty-section"/> + </xs:complexType> + </xs:element> + <xs:attributeGroup name="attlist.if-empty-section"> + <xs:attribute type="xs:string" name="section-name" use="required"/> + </xs:attributeGroup> <!-- ================ ACTIONS ================ --> <xs:element name="AllActions" abstract="true"/> Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java?rev=885346&r1=885345&r2=885346&view=diff ============================================================================== --- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java (original) +++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/screen/ModelScreenCondition.java Mon Nov 30 08:29:28 2009 @@ -123,6 +123,8 @@ return new IfEmpty(modelScreen, conditionElement); } else if ("if-entity-permission".equals(conditionElement.getNodeName())) { return new IfEntityPermission(modelScreen, conditionElement); + } else if ("if-empty-section".equals(conditionElement.getNodeName())) { + return new IfEmptySection(modelScreen, conditionElement); } else { throw new IllegalArgumentException("Condition element not supported with name: " + conditionElement.getNodeName()); } @@ -560,7 +562,19 @@ return permissionChecker.runPermissionCheck(context); } } -} + public static class IfEmptySection extends ScreenCondition { + protected FlexibleStringExpander sectionExdr; + public IfEmptySection(ModelScreen modelScreen, Element condElement) { + super (modelScreen, condElement); + this.sectionExdr = FlexibleStringExpander.getInstance(condElement.getAttribute("section-name")); + } + @Override + public boolean eval(Map<String, Object> context) { + Map<String, Object> sectionsList = UtilGenerics.toMap(context.get("sections")); + return !sectionsList.containsKey(this.sectionExdr.expandString(context)); + } + } +} \ No newline at end of file |
| Free forum by Nabble | Edit this page |
