svn commit: r514118 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget: form/ModelFormField.java html/HtmlFormRenderer.java

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

svn commit: r514118 - in /ofbiz/trunk/framework/widget/src/org/ofbiz/widget: form/ModelFormField.java html/HtmlFormRenderer.java

jacopoc
Author: jacopoc
Date: Sat Mar  3 02:23:42 2007
New Revision: 514118

URL: http://svn.apache.org/viewvc?view=rev&rev=514118
Log:
The widget form field action attribute is now stored with a flexible string; very useful to specify dynamic javascripts (such as an automatic row selection script for multiforms).

Modified:
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
    ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java?view=diff&rev=514118&r1=514117&r2=514118
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/form/ModelFormField.java Sat Mar  3 02:23:42 2007
@@ -89,7 +89,7 @@
     protected Integer position = null;
     protected String redWhen;
     protected String event;
-    protected String action;
+    protected FlexibleStringExpander action;
     protected FlexibleStringExpander useWhen;
 
     protected FieldInfo fieldInfo = null;
@@ -126,7 +126,7 @@
         this.requiredFieldStyle = fieldElement.getAttribute("required-field-style");
         this.redWhen = fieldElement.getAttribute("red-when");
         this.event = fieldElement.getAttribute("event");
-        this.action = fieldElement.getAttribute("action");
+        this.setAction(fieldElement.hasAttribute("action")? fieldElement.getAttribute("action"): null);
         this.setUseWhen(fieldElement.getAttribute("use-when"));
         this.idName = fieldElement.getAttribute("id-name");
         String sepColumns = fieldElement.getAttribute("separate-column");
@@ -246,7 +246,7 @@
             this.redWhen = overrideFormField.redWhen;
         if (UtilValidate.isNotEmpty(overrideFormField.event))
             this.event = overrideFormField.event;
-        if (UtilValidate.isNotEmpty(overrideFormField.action))
+        if (overrideFormField.action != null && !overrideFormField.action.isEmpty())
             this.action = overrideFormField.action;
         if (overrideFormField.useWhen != null && !overrideFormField.useWhen.isEmpty())
             this.useWhen = overrideFormField.useWhen;
@@ -770,8 +770,12 @@
     /**
      * @return
      */
-    public String getAction() {
-        return action;
+    public String getAction(Map context) {
+        if (this.action != null && this.action.getOriginal() != null) {
+            return action.expandString(context);
+        } else {
+            return null;
+        }
     }
 
 /**
@@ -1181,7 +1185,7 @@
      * @param string
      */
     public void setAction(String string) {
-        action = string;
+        this.action = new FlexibleStringExpander(string);
     }
 
     /**

Modified: ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java
URL: http://svn.apache.org/viewvc/ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java?view=diff&rev=514118&r1=514117&r2=514118
==============================================================================
--- ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java (original)
+++ ofbiz/trunk/framework/widget/src/org/ofbiz/widget/html/HtmlFormRenderer.java Sat Mar  3 02:23:42 2007
@@ -254,7 +254,7 @@
         }
 
         String event = modelFormField.getEvent();
-        String action = modelFormField.getAction();
+        String action = modelFormField.getAction(context);
         if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
             buffer.append(" ");
             buffer.append(event);
@@ -538,7 +538,7 @@
         ModelForm modelForm = modelFormField.getModelForm();
 
         String event = modelFormField.getEvent();
-        String action = modelFormField.getAction();
+        String action = modelFormField.getAction(context);
 
         buffer.append("<select");
 
@@ -718,7 +718,7 @@
         List allOptionValues = radioField.getAllOptionValues(context, modelForm.getDelegator());
         String currentValue = modelFormField.getEntry(context);
         String event = modelFormField.getEvent();
-        String action = modelFormField.getAction();
+        String action = modelFormField.getAction(context);
 
         // list out all options according to the option list
         Iterator optionValueIter = allOptionValues.iterator();
@@ -807,7 +807,7 @@
             buffer.append('"');
             
             event = modelFormField.getEvent();
-            action = modelFormField.getAction();
+            action = modelFormField.getAction(context);
             if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
                 buffer.append(" ");
                 buffer.append(event);
@@ -839,7 +839,7 @@
 
             
             event = modelFormField.getEvent();
-            action = modelFormField.getAction();
+            action = modelFormField.getAction(context);
             if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
                 buffer.append(" ");
                 buffer.append(event);
@@ -2091,7 +2091,7 @@
         }
 
         String event = modelFormField.getEvent();
-        String action = modelFormField.getAction();
+        String action = modelFormField.getAction(context);
         if (UtilValidate.isNotEmpty(event) && UtilValidate.isNotEmpty(action)) {
             buffer.append(" ");
             buffer.append(event);