You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jukka Välimaa <va...@gmail.com> on 2008/04/28 11:20:56 UTC

Url tag and automatic parameter setting

Hi,

I have a problem--more of an annoyance, really--with struts s:url tag. It
adds parameters into the result url without my say-so and I don't really
understand on what grounds. For example, I had the following in my jsp page:
<s:url id="addNewContract" action="ajaxEditContract">
    <s:param name="decorate" value="false" />
</s:url>

It evaluated to this:
ajaxEditContract.html?id=-3&amp;amp;decorate=false&amp;amp;dojo.preventCache=1209372598206&amp;amp;committerId=-7
&amp;dojo.preventCache=1209372600172&amp;decorate=false

I can understand it adds the ajax stuff automatically (although I don't know
why and when). What I don't understand is, why does it add committerId and
id as parameters. Both are available via getters in my action, and
committerId is used in the form that comes after I define the url. Id,
however, is not used at all in the page. To avoid problems, I have to create
the url like this:

<s:url id="addNewContract" action="ajaxEditContract">
    <s:param name="decorate" value="false" />
    <s:param name="id" value="null" />
</s:url>


To avoid problems in the future, I'd like to understand why exactly does the
url tag behave like this. I understand includeParams attribute is used to
set how the tag behaves with parameters, but there is no explanation in the
tag reference what "all" and "get" are supposed to do.

Can anyone tell me why does the url tag behave the way it does, or where I
could find an explanation?

Re: Url tag and automatic parameter setting

Posted by Laurie Harper <la...@holoweb.net>.
I'm not sure what you mean by that; setting it to 'none' means it will 
not add any parameters from the current request to the generated URL. 
You can explicitly add any parameters you want and obviously those will 
go into the URL, it just wont *copy* any parameters from the current 
request automatically.

L.

Jukka Välimaa wrote:
> Thank you for answering my question. I assume setting includeParams to
> 'none' means it will not automatically set any parameters at all, including
> ajax parameters?
> 
> On Mon, Apr 28, 2008 at 10:52 PM, Laurie Harper <la...@holoweb.net> wrote:
> 
>> Jukka Välimaa wrote:
>>
>>> Hi,
>>>
>>> I have a problem--more of an annoyance, really--with struts s:url tag.
>>> It
>>> adds parameters into the result url without my say-so and I don't really
>>> understand on what grounds. For example, I had the following in my jsp
>>> page:
>>> <s:url id="addNewContract" action="ajaxEditContract">
>>>    <s:param name="decorate" value="false" />
>>> </s:url>
>>>
>>> It evaluated to this:
>>>
>>> ajaxEditContract.html?id=-3&amp;amp;decorate=false&amp;amp;dojo.preventCache=1209372598206&amp;amp;committerId=-7
>>> &amp;dojo.preventCache=1209372600172&amp;decorate=false
>>>
>>> I can understand it adds the ajax stuff automatically (although I don't
>>> know
>>> why and when). What I don't understand is, why does it add committerId
>>> and
>>> id as parameters. Both are available via getters in my action, and
>>> committerId is used in the form that comes after I define the url. Id,
>>> however, is not used at all in the page. To avoid problems, I have to
>>> create
>>> the url like this:
>>>
>>> <s:url id="addNewContract" action="ajaxEditContract">
>>>    <s:param name="decorate" value="false" />
>>>    <s:param name="id" value="null" />
>>> </s:url>
>>>
>>>
>>> To avoid problems in the future, I'd like to understand why exactly does
>>> the
>>> url tag behave like this. I understand includeParams attribute is used
>>> to
>>> set how the tag behaves with parameters, but there is no explanation in
>>> the
>>> tag reference what "all" and "get" are supposed to do.
>>>
>>> Can anyone tell me why does the url tag behave the way it does, or where
>>> I
>>> could find an explanation?
>>>
>> The parameters in the generated URL come from the current request -- i.e.
>> the request that results in the tag being called. With includeParams set to
>> 'get', the URL includes the current request's GET parameters -- i.e. those
>> from the query string -- but not any POST parameters that may be present.
>> With 'all' the URL will include both GET and POST parameters.
>>
>> As you're probably aware, the default is 'get' and can be overridden in
>> your struts.xml / struts.properties.
>>
>> 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: Url tag and automatic parameter setting

Posted by Jukka Välimaa <va...@gmail.com>.
Thank you for answering my question. I assume setting includeParams to
'none' means it will not automatically set any parameters at all, including
ajax parameters?

On Mon, Apr 28, 2008 at 10:52 PM, Laurie Harper <la...@holoweb.net> wrote:

> Jukka Välimaa wrote:
>
> > Hi,
> >
> > I have a problem--more of an annoyance, really--with struts s:url tag.
> > It
> > adds parameters into the result url without my say-so and I don't really
> > understand on what grounds. For example, I had the following in my jsp
> > page:
> > <s:url id="addNewContract" action="ajaxEditContract">
> >    <s:param name="decorate" value="false" />
> > </s:url>
> >
> > It evaluated to this:
> >
> > ajaxEditContract.html?id=-3&amp;amp;decorate=false&amp;amp;dojo.preventCache=1209372598206&amp;amp;committerId=-7
> > &amp;dojo.preventCache=1209372600172&amp;decorate=false
> >
> > I can understand it adds the ajax stuff automatically (although I don't
> > know
> > why and when). What I don't understand is, why does it add committerId
> > and
> > id as parameters. Both are available via getters in my action, and
> > committerId is used in the form that comes after I define the url. Id,
> > however, is not used at all in the page. To avoid problems, I have to
> > create
> > the url like this:
> >
> > <s:url id="addNewContract" action="ajaxEditContract">
> >    <s:param name="decorate" value="false" />
> >    <s:param name="id" value="null" />
> > </s:url>
> >
> >
> > To avoid problems in the future, I'd like to understand why exactly does
> > the
> > url tag behave like this. I understand includeParams attribute is used
> > to
> > set how the tag behaves with parameters, but there is no explanation in
> > the
> > tag reference what "all" and "get" are supposed to do.
> >
> > Can anyone tell me why does the url tag behave the way it does, or where
> > I
> > could find an explanation?
> >
>
> The parameters in the generated URL come from the current request -- i.e.
> the request that results in the tag being called. With includeParams set to
> 'get', the URL includes the current request's GET parameters -- i.e. those
> from the query string -- but not any POST parameters that may be present.
> With 'all' the URL will include both GET and POST parameters.
>
> As you're probably aware, the default is 'get' and can be overridden in
> your struts.xml / struts.properties.
>
> L.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Url tag and automatic parameter setting

Posted by Laurie Harper <la...@holoweb.net>.
Jukka Välimaa wrote:
> Hi,
> 
> I have a problem--more of an annoyance, really--with struts s:url tag. It
> adds parameters into the result url without my say-so and I don't really
> understand on what grounds. For example, I had the following in my jsp page:
> <s:url id="addNewContract" action="ajaxEditContract">
>     <s:param name="decorate" value="false" />
> </s:url>
> 
> It evaluated to this:
> ajaxEditContract.html?id=-3&amp;amp;decorate=false&amp;amp;dojo.preventCache=1209372598206&amp;amp;committerId=-7
> &amp;dojo.preventCache=1209372600172&amp;decorate=false
> 
> I can understand it adds the ajax stuff automatically (although I don't know
> why and when). What I don't understand is, why does it add committerId and
> id as parameters. Both are available via getters in my action, and
> committerId is used in the form that comes after I define the url. Id,
> however, is not used at all in the page. To avoid problems, I have to create
> the url like this:
> 
> <s:url id="addNewContract" action="ajaxEditContract">
>     <s:param name="decorate" value="false" />
>     <s:param name="id" value="null" />
> </s:url>
> 
> 
> To avoid problems in the future, I'd like to understand why exactly does the
> url tag behave like this. I understand includeParams attribute is used to
> set how the tag behaves with parameters, but there is no explanation in the
> tag reference what "all" and "get" are supposed to do.
> 
> Can anyone tell me why does the url tag behave the way it does, or where I
> could find an explanation?

The parameters in the generated URL come from the current request -- 
i.e. the request that results in the tag being called. With 
includeParams set to 'get', the URL includes the current request's GET 
parameters -- i.e. those from the query string -- but not any POST 
parameters that may be present. With 'all' the URL will include both GET 
and POST parameters.

As you're probably aware, the default is 'get' and can be overridden in 
your struts.xml / struts.properties.

L.


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