[OFBiz] SVN: r5908 - trunk/framework/widget/src/org/ofbiz/widget/form

jonesde at svn.ofbiz.org jonesde at svn.ofbiz.org
Tue Oct 4 02:44:28 EDT 2005


Author: jonesde
Date: 2005-10-04 01:44:25 -0500 (Tue, 04 Oct 2005)
New Revision: 5908

Modified:
   trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
Log:
Small improvement to automatically fill in values from the parameters Map if the map for the field is null and no value is found in the root of the context, and if the useRequestParameter value is not false; for most single forms with a default-map this will work to fill in default values with no extra effort

Modified: trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
===================================================================
--- trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java	2005-10-04 04:32:49 UTC (rev 5907)
+++ trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java	2005-10-04 06:44:25 UTC (rev 5908)
@@ -622,9 +622,11 @@
         } else {
             //Debug.logInfo("Getting entry, isError false so getting from Map in context for field " + this.getName() + " of form " + this.modelForm.getName(), module);
             Map dataMap = this.getMap(context);
+            boolean dataMapIsContext = false;
             if (dataMap == null) {
                 //Debug.logInfo("Getting entry, no Map found with name " + this.getMapName() + ", using context for field " + this.getName() + " of form " + this.modelForm.getName(), module);
                 dataMap = context;
+                dataMapIsContext = true;
             }
             Object retVal = null;
             if (this.entryAcsr != null && !this.entryAcsr.isEmpty()) {
@@ -635,6 +637,18 @@
                 // if no entry name was specified, use the field's name
                 retVal = dataMap.get(this.name);
             }
+            
+            // this is a special case to fill in fields during a create by default from parameters passed in
+            if (dataMapIsContext && retVal == null && !Boolean.FALSE.equals(useRequestParameters)) {
+                Map parameters = (Map) context.get("parameters");
+                if (parameters != null) {
+                    if (this.entryAcsr != null && !this.entryAcsr.isEmpty()) {
+                        retVal = this.entryAcsr.get(parameters);
+                    } else {
+                        retVal = parameters.get(this.name);
+                    }
+                }
+            }
 
             if (retVal != null) {
                 // format number based on the user's locale



More information about the Svn mailing list