Commits

plightbo  committed ff3e204

WW-701: default ids and names for form and form elements

git-svn-id: http://svn.opensymphony.com/svn/webwork/trunk@640573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 8610d9e

Comments (0)

Files changed (2)

File src/java/com/opensymphony/webwork/views/jsp/ui/AbstractUITag.java

 package com.opensymphony.webwork.views.jsp.ui;
 
 import com.opensymphony.webwork.config.Configuration;
-import com.opensymphony.webwork.validators.JavaScriptVisitorFieldValidator;
-import com.opensymphony.webwork.validators.ScriptValidationAware;
 import com.opensymphony.webwork.views.jsp.ParameterizedTagSupport;
 import com.opensymphony.webwork.views.jsp.ui.template.TemplateEngine;
 import com.opensymphony.webwork.views.jsp.ui.template.TemplateEngineManager;
 import com.opensymphony.webwork.views.jsp.ui.template.TemplateRenderingContext;
-import com.opensymphony.webwork.views.util.JavaScriptValidationHolder;
-import com.opensymphony.xwork.ModelDriven;
 import com.opensymphony.xwork.config.ConfigurationException;
 import com.opensymphony.xwork.util.OgnlValueStack;
-import com.opensymphony.xwork.validator.*;
-import ognl.OgnlRuntime;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 
 import javax.servlet.jsp.JspException;
-import java.beans.PropertyDescriptor;
-import java.util.HashMap;
-import java.util.Iterator;
-import java.util.List;
-import java.util.Map;
 
 
 /**
             }
         }
 
+        FormTag formTag = (FormTag) findAncestorWithClass(this, FormTag.class);
+
         if (id != null) {
-            addParameter("id", getId());
+            addParameter("id", id);
+        } else if (formTag != null) {
+            addParameter("id", formTag.id + "_" + name);
         }
 
-        FormTag formTag = (FormTag) findAncestorWithClass(this, FormTag.class);
 
         if (formTag != null) {
             addParameter("form", formTag.getParameters());

File src/java/com/opensymphony/webwork/views/jsp/ui/FormTag.java

  */
 package com.opensymphony.webwork.views.jsp.ui;
 
+import com.opensymphony.webwork.ServletActionContext;
 import com.opensymphony.webwork.config.Configuration;
 import com.opensymphony.webwork.views.jsp.TagUtils;
 import com.opensymphony.webwork.views.util.JavaScriptValidationHolder;
 import com.opensymphony.webwork.views.util.UrlHelper;
-import com.opensymphony.webwork.ServletActionContext;
 import com.opensymphony.xwork.ObjectFactory;
 import com.opensymphony.xwork.config.ConfigurationManager;
 import com.opensymphony.xwork.config.entities.ActionConfig;
 
                 String result = UrlHelper.buildUrl(namespace + "/" + action + "." + Configuration.get("webwork.action.extension"), request, response, null);
                 addParameter("action", result);
+
+                // if the name isn't specified, use the action name
+                if (nameAttr == null) {
+                    nameAttr = action;
+                    addParameter("name", action);
+                }
+
+                // if the id isn't specified, use the action name
+                if (id == null) {
+                    id = action;
+                    addParameter("id", action);
+                }
             } else if (action != null) {
                 String result = UrlHelper.buildUrl(action, request, response, null);
                 addParameter("action", result);
     /**
      * Provide access to the JavaScriptValidationHolder so that the AbstractUITag
      * can trigger the registration of all validators.
+     *
      * @return
      */
     JavaScriptValidationHolder getJavaScriptValidationHolder() {