svn commit: r1293565 - in /ofbiz/trunk: applications/content/widget/content/ContentForms.xml framework/widget/dtd/widget-form.xsd framework/widget/src/org/ofbiz/widget/form/ModelForm.java framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

svn commit: r1293565 - in /ofbiz/trunk: applications/content/widget/content/ContentForms.xml framework/widget/dtd/widget-form.xsd framework/widget/src/org/ofbiz/widget/form/ModelForm.java framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java

jleroux@apache.org
Author: jleroux
Date: Sat Feb 25 10:00:43 2012
New Revision: 1293565

URL: http://svn.apache.org/viewvc?rev=1293565&view=rev
Log:
A patch from Nicolas Malin "On extend form, use call-parent-actions element to run the herited form action" https://issues.apache.org/jira/browse/OFBIZ-2889

On widget form at this time the actions on parents form is not executed if child form contains also actions.
A solution is to implement a new element call-parent-actions on <actions> and <row-actions> element.
for more info see : http://markmail.org/message/hy3puy3fhpzqo7fd

Modified:
    ofbiz/trunk/applications/content/widget/content/ContentForms.xml
    ofbiz/trunk/framework/widget/dtd/widget-form.xsd
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java

Modified: ofbiz/trunk/applications/content/widget/content/ContentForms.xml
URL: http://svn.apache.org/viewvc/ofbiz/trunk/applications/content/widget/content/ContentForms.xml?rev=1293565&r1=1293564&r2=1293565&view=diff
==============================================================================
--- ofbiz/trunk/applications/content/widget/content/ContentForms.xml (original)
+++ ofbiz/trunk/applications/content/widget/content/ContentForms.xml Sat Feb 25 10:00:43 2012
@@ -119,13 +119,8 @@ under the License.
     <form name="ListLookupContent" extends="ListContent" type="list" list-name="listIt" paginate-target="LookupContent"
         odd-row-style="alternate-row" default-table-style="basic-table hover-bar">
         <actions>
-            <service service-name="performFind" result-map="result" result-map-list="listIt">
-                <field-map field-name="inputFields" from-field="parameters"/>
-                <field-map field-name="entityName" value="Content"/>
-                <field-map field-name="orderBy" value="contentId"/>
-                <field-map field-name="viewIndex" from-field="viewIndex"/>
-                <field-map field-name="viewSize" from-field="viewSize"/>
-            </service>
+            <set field="parameters.sortField" from-field="parameters.sortField" default-value="contentId"/>
+            <call-parent-actions/>
         </actions>
         <field name="contentId">
             <hyperlink also-hidden="false" target-type="plain" description="${contentId}" target="javascript:set_value('${contentId}')"/>

Modified: ofbiz/trunk/framework/widget/dtd/widget-form.xsd
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/dtd/widget-form.xsd?rev=1293565&r1=1293564&r2=1293565&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/dtd/widget-form.xsd (original)
+++ ofbiz/trunk/framework/widget/dtd/widget-form.xsd Sat Feb 25 10:00:43 2012
@@ -1993,4 +1993,8 @@ under the License.
     <xs:attributeGroup name="attlist.select-field">
         <xs:attribute type="xs:string" name="field-name" use="required"/>
     </xs:attributeGroup>
+
+    <xs:element name="call-parent-actions" substitutionGroup="AllActions">
+        <xs:complexType/>
+    </xs:element>
 </xs:schema>

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=1293565&r1=1293564&r2=1293565&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 Sat Feb 25 10:00:43 2012
@@ -78,6 +78,7 @@ public class ModelForm extends ModelWidg
     protected String formLocation;
     protected String parentFormName;
     protected String parentFormLocation;
+    protected ModelForm parentModelForm;
     protected String type;
     protected FlexibleStringExpander target;
     protected String targetType;
@@ -261,6 +262,7 @@ public class ModelForm extends ModelWidg
             }
 
             if (parent != null) {
+                this.parentModelForm = parent;
                 this.type = parent.type;
                 this.target = parent.target;
                 this.containerId = parent.containerId;
@@ -1897,6 +1899,10 @@ public class ModelForm extends ModelWidg
         return this.parentFormLocation;
     }
 
+    public ModelForm getParentModelForm() {
+        return parentModelForm;
+    }
+
     public String getDefaultEntityName() {
         return this.defaultEntityName;
     }

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java?rev=1293565&r1=1293564&r2=1293565&view=diff
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormAction.java Sat Feb 25 10:00:43 2012
@@ -92,6 +92,8 @@ public abstract class ModelFormAction {
                 actions.add(new EntityAnd(modelForm, actionElement));
             } else if ("entity-condition".equals(actionElement.getNodeName())) {
                 actions.add(new EntityCondition(modelForm, actionElement));
+            } else if ("call-parent-actions".equals(actionElement.getNodeName())) {
+                actions.add(new CallParentActions(modelForm, actionElement));
             } else {
                 throw new IllegalArgumentException("Action element not supported with name: " + actionElement.getNodeName());
             }
@@ -545,4 +547,43 @@ public abstract class ModelFormAction {
             }
         }
     }
+
+    public static class CallParentActions extends ModelFormAction {
+        protected static enum ActionsKind {
+            ACTIONS,
+            ROW_ACTIONS
+        };
+
+        protected ActionsKind kind;
+
+        public CallParentActions(ModelForm modelForm, Element callParentActionsElement) {
+            super(modelForm, callParentActionsElement);
+            String parentName = callParentActionsElement.getParentNode().getNodeName();
+            if ("actions".equals(parentName)) {
+                kind = ActionsKind.ACTIONS;
+            } else if ("row-actions".equals(parentName)) {
+                kind = ActionsKind.ROW_ACTIONS;
+            } else {
+                throw new IllegalArgumentException("Action element not supported for call-parent-actions : " + parentName);
+            }
+
+            ModelForm parentModel = modelForm.getParentModelForm();
+            if (parentModel == null) {
+                throw new IllegalArgumentException("call-parent-actions can only be used with form extending another form");
+            }
+        }
+
+        @Override
+        public void runAction(Map<String, Object> context) {
+            ModelForm parentModel = modelForm.getParentModelForm();
+            switch (kind) {
+                case ACTIONS:
+                    parentModel.runFormActions(context);
+                    break;
+                case ROW_ACTIONS:
+                    ModelFormAction.runSubActions(parentModel.rowActions, context);
+                    break;
+            }
+        }
+    }
 }