Author: tmjee
Date: Mon Aug 14 09:37:26 2006
New Revision: 431380

URL: http://svn.apache.org/viewvc?rev=431380&view=rev
Log:
WW-769
  - Changed id for Submit component from random number (hashcode) to
    sequential number unique to the form component such that it is
predictable


Modified:
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/FormButton.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java?rev=431380&r1=431379&r2=431380&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java 
(original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/Form.java 
Mon Aug 14 09:37:26 2006
@@ -89,6 +89,8 @@
     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;
@@ -396,6 +398,17 @@
         }
 
         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++;
     }
 
 

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/FormButton.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/FormButton.java?rev=431380&r1=431379&r2=431380&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/FormButton.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/FormButton.java
 Mon Aug 14 09:37:26 2006
@@ -92,7 +92,7 @@
      *   <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) {
@@ -119,7 +119,11 @@
                                        _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);


Reply via email to