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: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to