svn commit: r654586 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java

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

svn commit: r654586 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java

adrianc
Author: adrianc
Date: Thu May  8 10:42:22 2008
New Revision: 654586

URL: http://svn.apache.org/viewvc?rev=654586&view=rev
Log:
Fixed a bug in the Form Widget where alt-target elements in extended forms were being added to the parent form's alt-targets. Also overriding an alt-target in an extended form works now.

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelForm.java

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=654586&r1=654585&r2=654586&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 Thu May  8 10:42:22 2008
@@ -270,7 +270,7 @@
                 this.hideHeader = parent.hideHeader;
                 this.clientAutocompleteFields = parent.clientAutocompleteFields;
 
-                this.altTargets = parent.altTargets;
+                this.altTargets.addAll(parent.altTargets);
                 this.actions = parent.actions;
                 this.rowActions = parent.rowActions;
                 
@@ -588,7 +588,12 @@
     }
 
     public void addAltTarget(AltTarget altTarget) {
-        altTargets.add(altTarget);
+        int index = altTargets.indexOf(altTarget);
+        if (index != -1) {
+            altTargets.set(index, altTarget);
+        } else {
+            altTargets.add(altTarget);
+        }
     }
 
     public void addAutoFieldsFromService(AutoFieldsService autoFieldsService) {
@@ -2547,6 +2552,12 @@
             this.useWhen = altTargetElement.getAttribute("use-when");
             this.target = altTargetElement.getAttribute("target");
         }
+        public int hashCode() {
+            return useWhen.hashCode();
+        }
+        public boolean equals(Object obj) {
+            return obj instanceof AltTarget && obj.hashCode() == this.hashCode();
+        }
     }
 
     public static class AutoFieldsService {