Anonymous avatar Anonymous committed 67732ff

- Changed id for Submit component from random number (hashcode) to sequential number unique to the form component
such that it is predictable

Issue number: WW-769
Obtained from:
Submitted by:
Reviewed by:

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

Comments (0)

Files changed (2)

src/java/com/opensymphony/webwork/components/Form.java

     public static final String OPEN_TEMPLATE = "form";
     public static final String TEMPLATE = "form-close";
 
+    private int sequence = 0;
+    
     protected String onsubmit;
     protected String action;
     protected String target;
 
         return validators;
     }
+    
+    /**
+     * Get a incrementing sequence unique to this <code>Form</code> component.
+     * It is used by <code>Form</code> component's child that might need a 
+     * sequence to make them unique.
+     * 
+     * @return int 
+     */
+    protected int getSequence() {
+    	return sequence++;
+    }
 
 
     /**

src/java/com/opensymphony/webwork/components/FormButton.java

      *   <li>[this_component_name]</li>
      *   <li>[this_component_action]_[this_component_method]</li>
      *   <li>[this_component_method]</li>
-     *   <li>[some_random_number]</li>
+     *   <li>[an increasing sequential number unique to the form starting with 0]</li>
      * </ol>
      */
     protected void populateComponentHtmlId(Form form) {
 					_tmp_id = _tmp_id + "_" + escape(method);
 				}
 			} else {
-				_tmp_id = _tmp_id + hashCode();
+				// if form is null, this component is used, without a form, i guess
+				// there's not much we could do then.
+				if (form != null) {
+					_tmp_id = _tmp_id + form.getSequence();
+				}
 			}
         }
 		addParameter("id", _tmp_id);
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.