1. opensymphony
  2. webwork

Commits

tmjee  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@2684573baa09-0c28-0410-bef9-dab3c582ae83

  • Participants
  • Parent commits 5938427
  • Branches master

Comments (0)

Files changed (2)

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

View file
     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++;
+    }
 
 
     /**

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

View file
      *   <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);