Author: bibryam
Date: Sun Jan 16 10:47:31 2011
New Revision: 1059529

URL: http://svn.apache.org/viewvc?rev=1059529&view=rev
Log:
Allow calling simple method in form actions

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

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=1059529&r1=1059528&r2=1059529&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 
Sun Jan 16 10:47:31 2011
@@ -48,6 +48,10 @@ import org.ofbiz.entity.finder.ByConditi
 import org.ofbiz.entity.finder.EntityFinderUtil;
 import org.ofbiz.entity.finder.PrimaryKeyFinder;
 import org.ofbiz.entity.util.EntityListIterator;
+import org.ofbiz.minilang.MiniLangException;
+import org.ofbiz.minilang.SimpleMethod;
+import org.ofbiz.minilang.method.MethodContext;
+import org.ofbiz.service.DispatchContext;
 import org.ofbiz.service.GenericServiceException;
 import org.ofbiz.service.ModelService;
 import org.ofbiz.widget.WidgetWorker;
@@ -303,6 +307,17 @@ public abstract class ModelFormAction {
                     Debug.logError(e, errMsg, module);
                     throw new IllegalArgumentException(errMsg);
                 }
+            } else if (location.endsWith(".xml")) {
+                Map<String, Object> localContext = FastMap.newInstance();
+                localContext.putAll(context);
+                DispatchContext ctx = this.modelForm.dispatchContext;
+                MethodContext methodContext = new MethodContext(ctx, 
localContext, null);
+                try {
+                    SimpleMethod.runSimpleMethod(location, method, 
methodContext);
+                    context.putAll(methodContext.getResults());
+                } catch (MiniLangException e) {
+                    throw new IllegalArgumentException("Error running simple 
method at location [" + location + "]", e);
+                }
             } else {
                 throw new IllegalArgumentException("For screen script actions 
the script type is not yet support for location:" + location);
             }


Reply via email to