You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by bu...@apache.org on 2003/02/26 20:40:42 UTC

DO NOT REPLY [Bug 17449] New: - Allow relative URL in action attribute of tag

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17449>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=17449

Allow relative URL in action attribute of <html:form .. > tag

           Summary: Allow relative URL in action attribute of <html:form ..
                    > tag
           Product: Struts
           Version: 1.1 RC1
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: Enhancement
          Priority: Other
         Component: Custom Tags
        AssignedTo: struts-dev@jakarta.apache.org
        ReportedBy: tennant@visi.com


I needed (for reasons beyond my control) to have <html:form..> create an 
action="" with a relative 
URL. Searching the mailing list, I ran across others who were seeking similar 
functionality. I 
wrote up a simple addition to FormTag.java that allows an optional isRelative 
attribute inside the 
form tag.

Image tags have something functionally equivalent, so I'm guessing it may be 
functionality you are 
interested in.

If you need something else from me, let me know.

Thanks,

Erik

This diff is against 1.1rc1


--- FormTag.java.rc1        2003-02-25 15:56:32.000000000 -0600
+++ FormTag.java.rc1.new        2003-02-25 15:56:32.000000000 -0600
@@ -214,6 +214,12 @@
      */
     protected String beanType = null;
 
+    /**
+     * Whether or not the action="" should be a relative URL. Default is
+     * false, to maintain backwards compatibility.
+     */
+    protected String isRelative = null;
+
     // ------------------------------------------------------------- Properties
 
     /**
@@ -488,6 +494,23 @@
 
     }
 
+    /**
+     * Is the action="" relative? a value of "true" (case insensitive) 
indicates it is
+     *
+     * @param value
+     */
+    public void setIsRelative (String value) {
+
+        this.isRelative = value;
+
+    }
+
+    public String getIsRelative () {
+
+        return isRelative;
+
+    }
+
     // --------------------------------------------------------- Public Methods
 
     /**
@@ -509,7 +532,11 @@
          results.append(" method=\"");
          results.append(method == null ? "post" : method);
          results.append("\" action=\"");
-         results.append(response.encodeURL(RequestUtils.getActionMappingURL
(action, pageContext)));
+        if ("true".equalsIgnoreCase(isRelative ) ) {
+            results.append(response.encodeURL(action));
+        } else {
+            results.append(response.encodeURL(RequestUtils.getActionMappingURL
(action, 
pageContext)));
+        }         
          results.append("\"");
          if (styleClass != null) {
              results.append(" class=\"");
@@ -696,6 +723,7 @@
         styleId = null;
         target = null;
         type = null;
+        isRelative = null;
 
     }
 
--- struts-html.tld.rc1        2003-02-25 15:56:32.000000000 -0600
+++ struts-html.tld.rc1.new        2003-02-25 15:56:32.000000000 -0600
@@ -618,6 +618,11 @@
 <rtexprvalue>true</rtexprvalue>
 </attribute>
 <attribute>
+<name>isRelative</name>
+<required>false</required>
+<rtexprvalue>true</rtexprvalue>
+</attribute>
+<attribute>
 <name>enctype</name>
 <required>false</required>
 <rtexprvalue>true</rtexprvalue>

---------------------------------------------------------------------
To unsubscribe, e-mail: struts-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: struts-dev-help@jakarta.apache.org