svn commit: r965154 - /ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy

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

svn commit: r965154 - /ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy

jonesde
Author: jonesde
Date: Sun Jul 18 02:24:21 2010
New Revision: 965154

URL: http://svn.apache.org/viewvc?rev=965154&view=rev
Log:
Added support for passing extra server-side parameters in a Map from the screen definition, ie screen actions

Modified:
    ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy

Modified: ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy?rev=965154&r1=965153&r2=965154&view=diff
==============================================================================
--- ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy (original)
+++ ofbiz/trunk/framework/common/webcommon/WEB-INF/actions/includes/FindAutocompleteOptions.groovy Sun Jul 18 02:24:21 2010
@@ -18,6 +18,7 @@
  */
 
 import org.ofbiz.base.util.StringUtil;
+import org.ofbiz.base.util.Debug;
 import org.ofbiz.entity.util.EntityFindOptions;
 import org.ofbiz.entity.condition.EntityCondition;
 import org.ofbiz.entity.condition.EntityConditionList;
@@ -26,13 +27,13 @@ import org.ofbiz.entity.condition.Entity
 import org.ofbiz.entity.condition.EntityFunction;
 import org.ofbiz.entity.condition.EntityOperator;
 
-andExprs = [];
-entityName = context.entityName;
-searchFields = context.searchFields;
-displayFields = context.displayFields ?: searchFields;
-searchValueFieldName = parameters.searchValueField;
+def andExprs = [];
+def entityName = context.entityName;
+def searchFields = context.searchFields;
+def displayFields = context.displayFields ?: searchFields;
+def searchValueFieldName = parameters.searchValueField;
 if (searchValueFieldName) fieldValue = parameters.get(searchValueFieldName);
-searchType = context.searchType;
+def searchType = context.searchType;
 
 if (searchFields && fieldValue) {
     searchFieldsList = StringUtil.toList(searchFields);
@@ -58,6 +59,18 @@ if (searchFields && fieldValue) {
     }
 }
 
+/* the following is part of an attempt to handle additional parameters that are passed in from other form fields at run-time,
+ * but that is not supported by the scrip.aculo.us Ajax.Autocompleter, but this is still useful to pass parameters from the
+ * lookup screen definition:
+ */
+def conditionFields = context.conditionFields;
+if (conditionFields) {
+    // these fields are for additonal conditions, this is a Map of name/value pairs
+    for (conditionFieldEntry in conditionFields.entrySet()) {
+        andExprs.add(EntityCondition.makeCondition(EntityFieldValue.makeFieldValue(conditionFieldEntry.getKey()), EntityOperator.EQUALS, conditionFieldEntry.getValue()));    
+    }
+}
+
 if (andExprs && entityName && displayFieldsSet) {
     entityConditionList = EntityCondition.makeCondition(andExprs, EntityOperator.OR);