svn commit: r505882 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java

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

svn commit: r505882 - /ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java

jacopoc
Author: jacopoc
Date: Sun Feb 11 02:52:35 2007
New Revision: 505882

URL: http://svn.apache.org/viewvc?view=rev&rev=505882
Log:
Now the HtmlFormWrapper object can be created using the old relative paths to the form def file or the new component:// sintax.
Thanks to Chris Howe for the initial patch, that I have modified to make it backward compatible with the old syntax.
This will improve the scripts reusability. OFBIZ-278

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java?view=diff&rev=505882&r1=505881&r2=505882
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormWrapper.java Sun Feb 11 02:52:35 2007
@@ -29,6 +29,8 @@
 import org.ofbiz.base.util.UtilHttp;
 import org.ofbiz.base.util.UtilValidate;
 import org.ofbiz.base.util.collections.MapStack;
+import org.ofbiz.entity.GenericDelegator;
+import org.ofbiz.service.LocalDispatcher;
 import org.ofbiz.widget.form.FormFactory;
 import org.ofbiz.widget.form.FormStringRenderer;
 import org.ofbiz.widget.form.ModelForm;
@@ -60,7 +62,14 @@
         this.request = request;
         this.response = response;
         
-        this.modelForm = FormFactory.getFormFromWebappContext(resourceName, formName, request);
+        try {
+            GenericDelegator delegator = (GenericDelegator) request.getAttribute("delegator");
+            LocalDispatcher dispatcher = (LocalDispatcher) request.getAttribute("dispatcher");
+            this.modelForm = FormFactory.getFormFromLocation(resourceName, formName, delegator, dispatcher);
+        } catch(IllegalArgumentException iae) {
+            Debug.logWarning("Could not find form with name [" + formName + "] in class resource [" + resourceName + "], will try to load it using relative path syntax.", module);
+            this.modelForm = FormFactory.getFormFromWebappContext(resourceName, formName, request);
+        }
 
         this.renderer = new HtmlFormRenderer(request, response);