You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@struts.apache.org by Erik Tennant <te...@visi.com> on 2003/02/25 23:04:16 UTC

[PATCH] Relative action URL's for FormTag

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


Re: [PATCH] Relative action URL's for FormTag

Posted by Eddie Bush <ek...@swbell.net>.
Erik Tennant wrote:

>ok, I entered it in as bug 17449.
>
Good job - thanks!

>Unfortunately the firewall at work keeps me from accessing the cvs repository, which is why I did a 
>diff from rc1 instead of from cvs.  Maybe there is a cvs client that can operate through a http 
>proxy- I will have to go look into that. Although I assume since rc1 was just released that the cvs 
>head version is the same as rc1 at this point?
>
Hrm ... yeah should be pretty close.  If not then CVS generally does a 
pretty good job of figuring out what needs done.  If it turns out to be 
a problem then whoever applies your patch will just "eye-ball" the patch 
and figure out what needs done.  That doesn't generally happen though. 
 I wouldn't worry about it as close as we are to RC1.  Of course, if you 
find yourself able to do the diff against RC1 later on you can always 
post and update and just make note of what you're doing ... or leave it 
for the commiter handling the bug to figure out ;-)  Generally, most of 
us appreciate someone pointing us in the right direction though :-) 
 Just put something like "Updated patch - please use this instead of 
attachment #####".  That should suffice.

>Thanks,
>
>Erik
>
No, thank *you* ;-)

-- 
Eddie Bush





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


Re: [PATCH] Relative action URL's for FormTag

Posted by Erik Tennant <te...@visi.com>.
ok, I entered it in as bug 17449.

Unfortunately the firewall at work keeps me from accessing the cvs repository, which is why I did a 
diff from rc1 instead of from cvs.  Maybe there is a cvs client that can operate through a http 
proxy- I will have to go look into that. Although I assume since rc1 was just released that the cvs 
head version is the same as rc1 at this point?

Thanks,

Erik


> ----- Message from ekbush@swbell.net ---------
>     Date: Wed, 26 Feb 2003 14:01:11 -0600
>     From: Eddie Bush <ek...@swbell.net>
> Reply-To: Struts Developers List <st...@jakarta.apache.org>
>  Subject: Re: [PATCH] Relative action URL's for FormTag
>       To: Struts Developers List <st...@jakarta.apache.org>
> 
> Erik,
> 
> If you could put your patch into Bugzilla (file it against the bug
> report, please - create a bug report for issues that don't have one yet)
> we'd much appreciate it.  By just sending it to the list, you risk it
> being lost -- and very likely missed or forgotten.  If it's in Bugzilla,
> whichever one of us gets to tackle that bug will have your patch right
> there for consideration.  If possible, always submit output from 'cvs
> diff -u' (looks like that's probably what you did - thanks!) and ... I
> suppose that's it.
> 
> http://issues.apache.org/bugzilla
> 
> Thanks for the effort!

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


Re: [PATCH] Relative action URL's for FormTag

Posted by Eddie Bush <ek...@swbell.net>.
Erik,

If you could put your patch into Bugzilla (file it against the bug 
report, please - create a bug report for issues that don't have one yet) 
we'd much appreciate it.  By just sending it to the list, you risk it 
being lost -- and very likely missed or forgotten.  If it's in Bugzilla, 
whichever one of us gets to tackle that bug will have your patch right 
there for consideration.  If possible, always submit output from 'cvs 
diff -u' (looks like that's probably what you did - thanks!) and ... I 
suppose that's it.

http://issues.apache.org/bugzilla

Thanks for the effort!

Erik Tennant wrote:

>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
>

-- 
Eddie Bush





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