You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Pierre Thibaudeau <pi...@gmail.com> on 2008/09/18 18:50:19 UTC
[S2] not including null-params in URL of GET-submitted form
Is there a way to avoid null-valued (or empty-valued) parameters to be
explicitely mentioned in the URL generated by a form submitted through the
GET method?
For instance, here's a form:
<s:form action="myAction" method="get">
<s:textfield name="param1" />
<s:textfield name="param2" />
<s:submit />
</s:form>
If the user types "FOO" in the first textfield and nothing in the second,
the submitted URL will be something like:
http://myhost.com/myAction.action?param1=FOO¶m2=
Can I get rid of the "param2=" part, which serves no purpose?
(The alternative would be to POST the method to an action that would merely
redirect to the desired action, dropping the undesired parameters along the
way.)
Re: [S2] not including null-params in URL of GET-submitted form
Posted by Gabriel Belingueres <be...@gmail.com>.
try disabling the empty fields in the form's onsubmit event.
2008/9/18 Laurie Harper <la...@holoweb.net>:
> Pierre Thibaudeau wrote:
>>
>> Is there a way to avoid null-valued (or empty-valued) parameters to be
>> explicitely mentioned in the URL generated by a form submitted through the
>> GET method?
>>
>> For instance, here's a form:
>>
>> <s:form action="myAction" method="get">
>> <s:textfield name="param1" />
>> <s:textfield name="param2" />
>> <s:submit />
>> </s:form>
>>
>> If the user types "FOO" in the first textfield and nothing in the second,
>> the submitted URL will be something like:
>> http://myhost.com/myAction.action?param1=FOO¶m2=
>>
>> Can I get rid of the "param2=" part, which serves no purpose?
>>
>> (The alternative would be to POST the method to an action that would
>> merely
>> redirect to the desired action, dropping the undesired parameters along
>> the
>> way.)
>
> This is expected behabiour; short of doing some JavaScript-fu on form
> submit, I don't think you can avoid the empty params. That said, if the form
> submit is going to cause any data updates on the server, it really should be
> a POST anyway -- and if not, I'm not sure why the 'noise' in the URL
> matters.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: [S2] not including null-params in URL of GET-submitted form
Posted by Laurie Harper <la...@holoweb.net>.
Pierre Thibaudeau wrote:
> Is there a way to avoid null-valued (or empty-valued) parameters to be
> explicitely mentioned in the URL generated by a form submitted through the
> GET method?
>
> For instance, here's a form:
>
> <s:form action="myAction" method="get">
> <s:textfield name="param1" />
> <s:textfield name="param2" />
> <s:submit />
> </s:form>
>
> If the user types "FOO" in the first textfield and nothing in the second,
> the submitted URL will be something like:
> http://myhost.com/myAction.action?param1=FOO¶m2=
>
> Can I get rid of the "param2=" part, which serves no purpose?
>
> (The alternative would be to POST the method to an action that would merely
> redirect to the desired action, dropping the undesired parameters along the
> way.)
This is expected behabiour; short of doing some JavaScript-fu on form
submit, I don't think you can avoid the empty params. That said, if the
form submit is going to cause any data updates on the server, it really
should be a POST anyway -- and if not, I'm not sure why the 'noise' in
the URL matters.
L.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org