You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Kusuma Haranath Atmakuri <ha...@yahoo.com> on 2010/03/15 02:36:44 UTC

Parameter in If tag

>From the actions config, a parameter is being passed: 
<action ...>

    <result>main.jsp?paramName=paramValue</result>

When tried to access the paramName, it's fine when used in 'property' tag.
<s:property value=%{#parameters.paramName} /> will print 'paramValue'. 

But when used in 'If' tag, it does NOT. Is there anything missing here? Tried all the combinations of #, {}, %, double quotes and single quotes. Any help would be greatly appreciated.
<s:if test="%{#parameters.paramName=='paramValue'}"> will return FALSE.

Thank you!


      

Re: Parameter in If tag

Posted by Wes Wannemacher <we...@wantii.com>.
On Thu, Mar 18, 2010 at 11:07 PM, Kusuma Haranath Atmakuri
<ha...@yahoo.com> wrote:
> <s:if test="%{#parameters['paramName'][0] =='paramValue'}">
>
> Thanks a lot! This worked! "parameters['paramName']" returns an array?
>
>

Yeah, it's a bit of a pain sometimes, but there is nothing that stops
someone from writing html like this -

<form ...>

<input name="foo" value="" type="text" />
<input name="foo" value="" type="text" />

</form>

In this case, you can retrieve all of the values submitted for "foo"
as an array. It's just one of those details people sometimes forget
when you get away from dealing directly with request parameters.

-Wes


-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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


Re: Parameter in If tag

Posted by Kusuma Haranath Atmakuri <ha...@yahoo.com>.
<s:if test="%{#parameters['paramName'][0] =='paramValue'}"> 

Thanks a lot! This worked! "parameters['paramName']" returns an array? 


-- K


________________________________
From: Wes Wannemacher <we...@wantii.com>
To: Struts Users Mailing List <us...@struts.apache.org>
Sent: Mon, March 15, 2010 4:16:14 PM
Subject: Re: Parameter in If tag

Parameters that aren't bound to an action property can be tricky... I
would try some of the following to see if you can figure out what's
going on ->

<s:if test="%{#parameters.paramName.0 =='paramValue'}">
<s:if test="%{#parameters['paramName'] =='paramValue'}">
<s:if test="%{#parameters['paramName'][0] =='paramValue'}">

-Wes

On Mon, Mar 15, 2010 at 2:45 PM, Kusuma Haranath Atmakuri
<ha...@yahoo.com> wrote:
> By the way, I am using Struts 2.1.8.1. Actually it was a WebWork app and converting that into Struts2. Referring a parameter was so easy in ww with just '$paramName'. It's weird that I am stuck at such a simple thing. Any light on this would be of great help.
>
> Thank you!
>
>
>
>
> ________________________________
> To: user@struts.apache.org
> Sent: Sun, March 14, 2010 8:36:44 PM
> Subject: Parameter in If tag
>
> From the actions config, a parameter is being passed:
> <action ...>
>
>    <result>main.jsp?paramName=paramValue</result>
>
> When tried to access the paramName, it's fine when used in 'property' tag.
> <s:property value=%{#parameters.paramName} /> will print 'paramValue'.
>
> But when used in 'If' tag, it does NOT. Is there anything missing here? Tried all the combinations of #, {}, %, double quotes and single quotes. Any help would be greatly appreciated.
> <s:if test="%{#parameters.paramName=='paramValue'}"> will return FALSE.
>
> Thank you!
>
>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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


      

Re: Parameter in If tag

Posted by Wes Wannemacher <we...@wantii.com>.
Parameters that aren't bound to an action property can be tricky... I
would try some of the following to see if you can figure out what's
going on ->

<s:if test="%{#parameters.paramName.0 =='paramValue'}">
<s:if test="%{#parameters['paramName'] =='paramValue'}">
<s:if test="%{#parameters['paramName'][0] =='paramValue'}">

-Wes

On Mon, Mar 15, 2010 at 2:45 PM, Kusuma Haranath Atmakuri
<ha...@yahoo.com> wrote:
> By the way, I am using Struts 2.1.8.1. Actually it was a WebWork app and converting that into Struts2. Referring a parameter was so easy in ww with just '$paramName'. It's weird that I am stuck at such a simple thing. Any light on this would be of great help.
>
> Thank you!
>
>
>
>
> ________________________________
> To: user@struts.apache.org
> Sent: Sun, March 14, 2010 8:36:44 PM
> Subject: Parameter in If tag
>
> From the actions config, a parameter is being passed:
> <action ...>
>
>    <result>main.jsp?paramName=paramValue</result>
>
> When tried to access the paramName, it's fine when used in 'property' tag.
> <s:property value=%{#parameters.paramName} /> will print 'paramValue'.
>
> But when used in 'If' tag, it does NOT. Is there anything missing here? Tried all the combinations of #, {}, %, double quotes and single quotes. Any help would be greatly appreciated.
> <s:if test="%{#parameters.paramName=='paramValue'}"> will return FALSE.
>
> Thank you!
>
>
>



-- 
Wes Wannemacher

Head Engineer, WanTii, Inc.
Need Training? Struts, Spring, Maven, Tomcat...
Ask me for a quote!

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


Re: Parameter in If tag

Posted by Kusuma Haranath Atmakuri <ha...@yahoo.com>.
By the way, I am using Struts 2.1.8.1. Actually it was a WebWork app and converting that into Struts2. Referring a parameter was so easy in ww with just '$paramName'. It's weird that I am stuck at such a simple thing. Any light on this would be of great help. 

Thank you!




________________________________
To: user@struts.apache.org
Sent: Sun, March 14, 2010 8:36:44 PM
Subject: Parameter in If tag

>From the actions config, a parameter is being passed: 
<action ...>

    <result>main.jsp?paramName=paramValue</result>

When tried to access the paramName, it's fine when used in 'property' tag.
<s:property value=%{#parameters.paramName} /> will print 'paramValue'. 

But when used in 'If' tag, it does NOT. Is there anything missing here? Tried all the combinations of #, {}, %, double quotes and single quotes. Any help would be greatly appreciated.
<s:if test="%{#parameters.paramName=='paramValue'}"> will return FALSE.

Thank you!