1. opensymphony
  2. webwork

Commits

plightbo  committed e19b97a

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

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

  • Participants
  • Parent commits ff3e204
  • Branches master

Comments (0)

Files changed (6)

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

View file
  • Ignore whitespace
             } else if (action != null) {
                 String result = UrlHelper.buildUrl(action, request, response, null);
                 addParameter("action", result);
+
+                // cut out anything between / and . should be the id and name
+                int slash = result.lastIndexOf('/');
+                int dot = result.indexOf('.', slash);
+                if (dot != -1) {
+                    id = result.substring(slash + 1, dot);
+                } else {
+                    id = result.substring(slash + 1);
+                }
+                addParameter("id", id);
             }
 
             // only create the javaScriptValidationHolder if the actionName,and class is known

File src/test/com/opensymphony/webwork/views/jsp/ui/Formtag-1.txt

View file
  • Ignore whitespace
-<form name="myForm" action="myAction" method="POST" enctype="myEncType" >
+<form id="myAction" name="myForm" action="myAction" method="POST" enctype="myEncType" >
 <table class="wwFormTable">
 </table>
 </form>

File src/test/com/opensymphony/webwork/views/jsp/ui/Formtag-2.txt

View file
  • Ignore whitespace
-<form name="myForm" action="/testAction.action" method="POST" enctype="myEncType" onsubmit="return(myForm_validate())" >
+<form id="testAction" name="myForm" action="/testAction.action" method="POST" enctype="myEncType" onsubmit="return(myForm_validate())" >
 <table class="wwFormTable">
 <tr>
  <td align="right" valign="top"></td>
- <td><input type="text" name="foo" value="bar" /></td>
+ <td><input type="text" name="foo" value="bar" id="testAction_foo" /></td>
 </tr>
 <tr>
  <td align="right" valign="top"></td>
- <td><input type="text" name="user.name" value="Bobby" /></td>
+ <td><input type="text" name="user.name" value="Bobby" id="testAction_user.name" /></td>
 </tr>
 </table>
 </form>

File src/test/com/opensymphony/webwork/views/jsp/ui/Formtag-2b.txt

View file
  • Ignore whitespace
-<form name="myForm" action="/testAction.action" method="POST" enctype="myEncType" onsubmit="return(myForm_validate())" >
+<form id="testAction" name="myForm" action="/testAction.action" method="POST" enctype="myEncType" onsubmit="return(myForm_validate())" >
 <table class="wwFormTable">
 <tr>
  <td align="right" valign="top"></td>
- <td><input type="text" name="foo" value="bar" /></td>
+ <td><input type="text" name="foo" value="bar" id="testAction_foo" /></td>
 </tr>
 <tr>
  <td align="right" valign="top"></td>
- <td><input type="text" name="user.name" value="Bobby" /></td>
+ <td><input type="text" name="user.name" value="Bobby" id="testAction_user.name" /></td>
 </tr>
 </table>
 </form>
   return null;
 }
 </script>
-<form name="myForm" action="/testAction.action" method="POST" enctype="myEncType" onsubmit="return(myForm_validate())" >
+<form id="testAction" name="myForm" action="/testAction.action" method="POST" enctype="myEncType" onsubmit="return(myForm_validate())" >
 <table class="wwFormTable">
 <tr>
  <td align="right" valign="top"></td>
- <td><input type="text" name="foo" value="bar" /></td>
+ <td><input type="text" name="foo" value="bar" id="testAction_foo" /></td>
 </tr>
 <tr>
  <td align="right" valign="top"></td>
- <td><input type="text" name="user.name" value="Bobby" /></td>
+ <td><input type="text" name="user.name" value="Bobby" id="testAction_user.name" /></td>
 </tr>
 </table>
 </form>

File src/test/com/opensymphony/webwork/views/jsp/ui/Formtag-3.txt

View file
  • Ignore whitespace
-<form name="myForm" action="/testNamespace/testNamespaceAction.action" method="POST" >
+<form id="testNamespaceAction" name="myForm" action="/testNamespace/testNamespaceAction.action" method="POST" >
 <table class="wwFormTable">
 </table>
 </form>

File src/test/com/opensymphony/webwork/views/jsp/ui/Formtag-5.txt

View file
  • Ignore whitespace
-<form name="myForm" action="/testNamespace/testNamespaceAction.jspa" method="POST" >
+<form id="testNamespaceAction" name="myForm" action="/testNamespace/testNamespaceAction.jspa" method="POST" >
 <table class="wwFormTable">
 </table>
 </form>