Author: wesw
Date: Fri Dec  5 20:53:06 2008
New Revision: 723948

URL: http://svn.apache.org/viewvc?rev=723948&view=rev
Log:
ServletUrlRenderer patch to fix s:form tag when using dynamic method 
invocation. Per WW-2727 and WW-2768, thanks for the patch Lukasz Racon

Added:
    
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-23.txt
   (with props)
Modified:
    
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java
    
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java

Modified: 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java?rev=723948&r1=723947&r2=723948&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java
 (original)
+++ 
struts/struts2/trunk/core/src/main/java/org/apache/struts2/components/ServletUrlRenderer.java
 Fri Dec  5 20:53:06 2008
@@ -131,10 +131,10 @@
         String actionMethod = nameMapping.getMethod();
 
                final ActionConfig actionConfig = 
formComponent.configuration.getRuntimeConfiguration().getActionConfig(
-                               namespace, action);
+                               namespace, actionName);
                if (actionConfig != null) {
 
-                       ActionMapping mapping = new ActionMapping(action, 
namespace, actionMethod, formComponent.parameters);
+                       ActionMapping mapping = new ActionMapping(actionName, 
namespace, actionMethod, formComponent.parameters);
                        String result = 
UrlHelper.buildUrl(formComponent.actionMapper.getUriFromActionMapping(mapping),
                                        formComponent.request, 
formComponent.response, null);
                        formComponent.addParameter("action", result);
@@ -153,14 +153,14 @@
 
                        // if the name isn't specified, use the action name
                        if (formComponent.name == null) {
-                               formComponent.addParameter("name", action);
+                               formComponent.addParameter("name", actionName);
                        }
 
                        // if the id isn't specified, use the action name
-                       if (formComponent.getId() == null  && action!=null ) {
-                               formComponent.addParameter("id", 
formComponent.escape(action));
+                       if (formComponent.getId() == null  && actionName!=null 
) {
+                               formComponent.addParameter("id", 
formComponent.escape(actionName));
                        }
-               } else if (action != null) {
+               } else if (actionName != null) {
                        // Since we can't find an action alias in the 
configuration, we just
                        // assume the action attribute supplied is the path to 
be used as
                        // the URI this form is submitting to.
@@ -168,10 +168,10 @@
             // Warn user that the specified namespace/action combo
             // was not found in the configuration.
             if (namespace != null) {
-              LOG.warn("No configuration found for the specified action: '" + 
action + "' in namespace: '" + namespace + "'. Form action defaulting to 
'action' attribute's literal value.");
+              LOG.warn("No configuration found for the specified action: '" + 
actionName + "' in namespace: '" + namespace + "'. Form action defaulting to 
'action' attribute's literal value.");
             }
 
-                       String result = UrlHelper.buildUrl(action, 
formComponent.request, formComponent.response, null);
+                       String result = UrlHelper.buildUrl(actionName, 
formComponent.request, formComponent.response, null);
                        formComponent.addParameter("action", result);
 
                        // namespace: cut out anything between the start and 
the last /

Modified: 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java?rev=723948&r1=723947&r2=723948&view=diff
==============================================================================
--- 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
 (original)
+++ 
struts/struts2/trunk/core/src/test/java/org/apache/struts2/views/jsp/ui/FormTagTest.java
 Fri Dec  5 20:53:06 2008
@@ -67,6 +67,22 @@
 
         verify(FormTag.class.getResource("Formtag-9.txt"));
     }
+    
+    public void testFormWithActionAttributeContainingBothActionAndDMIMethod() 
throws Exception {
+        FormTag tag = new FormTag();
+        tag.setPageContext(pageContext);
+        tag.setName("myForm");
+        tag.setMethod("post");
+        tag.setAcceptcharset("UTF-8");
+        tag.setAction("testAction!testMethod");
+        tag.setEnctype("myEncType");
+        tag.setTitle("mytitle");
+        tag.setOnsubmit("submitMe()");
+        tag.doStartTag();
+        tag.doEndTag();
+
+        verify(FormTag.class.getResource("Formtag-23.txt"));
+    }    
 
     public void testFormWithFocusElement() throws Exception {
         FormTag tag = new FormTag();

Added: 
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-23.txt
URL: 
http://svn.apache.org/viewvc/struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-23.txt?rev=723948&view=auto
==============================================================================
--- 
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-23.txt
 (added)
+++ 
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-23.txt
 Fri Dec  5 20:53:06 2008
@@ -0,0 +1,4 @@
+<form id="testAction" name="myForm" onsubmit="submitMe(); return true;" 
action="/testAction!testMethod.action" method="post" enctype="myEncType" 
title="mytitle" accept-charset="UTF-8">
+<table class="wwFormTable">
+</table>
+</form>

Propchange: 
struts/struts2/trunk/core/src/test/resources/org/apache/struts2/views/jsp/ui/Formtag-23.txt
------------------------------------------------------------------------------
    svn:eol-style = native


Reply via email to