You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by foo bar <li...@gmail.com> on 2009/12/22 11:36:34 UTC

if tag with #parameters

Hi all,

I'm testing for the existence of a request parameter in a jsp page in Struts 2

<%@ taglib prefix="s" uri="/struts-tags"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<s:property value="#parameters.messageKey"/><br/>
<s:if test="%{#parameters.messageKey == 'yes'}">
yes
</s:if>
<s:else>
no
</s:else>

But, whatever I do, result is always "no"

Tested with these cases:

test.jsp
test.jsp?messageKey=
test.jsp?messageKey=yes
test.jsp?messageKey=no

Changed it to <s:if test="#parameters.messageKey == 'yes'">, same results
Changed it to <s:if test="{#parameters.messageKey == 'yes'}">, results
are negated as above, ie you got "no" when previously you got "yes"

What's the solution here ?

Cheers

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


Re: if tag with #parameters

Posted by xerax nono <xr...@gmail.com>.
I think that the correct test is:

<s:property value="#messageKey"/><br/>
<s:if test="%{#messageKey == 'yes'}">
yes
2009/12/22 foo bar <li...@gmail.com>

> Hi all,
>
> I'm testing for the existence of a request parameter in a jsp page in
> Struts 2
>
> <%@ taglib prefix="s" uri="/struts-tags"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
> <s:property value="#parameters.messageKey"/><br/>
> <s:if test="%{#parameters.messageKey == 'yes'}">
> yes
> </s:if>
> <s:else>
> no
> </s:else>
>
> But, whatever I do, result is always "no"
>
> Tested with these cases:
>
> test.jsp
> test.jsp?messageKey=
> test.jsp?messageKey=yes
> test.jsp?messageKey=no
>
> Changed it to <s:if test="#parameters.messageKey == 'yes'">, same results
> Changed it to <s:if test="{#parameters.messageKey == 'yes'}">, results
> are negated as above, ie you got "no" when previously you got "yes"
>
> What's the solution here ?
>
> Cheers
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Serafin Hernandez Blazquez
649 81 64 87

Re: if tag with #parameters

Posted by Gabriel Belingueres <be...@gmail.com>.
Yes, parameters are String arrays. As a side note, see the following
post because sometimes OGNL evaluates things differently:

http://www.mail-archive.com/user@struts.apache.org/msg80015.html

2009/12/22 foo bar <li...@gmail.com>:
> Hi,
>
> I would prefer not to use getter/setter.
> What I really want to know is, why is this not working as expected ?
>
> Anyway, I solved it
>
> <s:if test="#parameters.messageKey[0] == 'yes'">
>
> #parameters.messageKey is of type String[], which make sense now
>
>
> On Tue, Dec 22, 2009 at 9:46 PM, Saeed Iqbal <sa...@gmail.com> wrote:
>> If it is a request parameter, then make a setter for it to get set and
>> getter to retrieve it and use % instead of #
>>
>> If you want to have the parameter in the page context use the s:set with id
>>
>>
>>
>> On Tue, Dec 22, 2009 at 3:36 PM, foo bar <li...@gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I'm testing for the existence of a request parameter in a jsp page in
>>> Struts 2
>>>
>>> <%@ taglib prefix="s" uri="/struts-tags"%>
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
>>> "http://www.w3.org/TR/html4/strict.dtd">
>>> <s:property value="#parameters.messageKey"/><br/>
>>> <s:if test="%{#parameters.messageKey == 'yes'}">
>>> yes
>>> </s:if>
>>> <s:else>
>>> no
>>> </s:else>
>>>
>>> But, whatever I do, result is always "no"
>>>
>>> Tested with these cases:
>>>
>>> test.jsp
>>> test.jsp?messageKey=
>>> test.jsp?messageKey=yes
>>> test.jsp?messageKey=no
>>>
>>> Changed it to <s:if test="#parameters.messageKey == 'yes'">, same results
>>> Changed it to <s:if test="{#parameters.messageKey == 'yes'}">, results
>>> are negated as above, ie you got "no" when previously you got "yes"
>>>
>>> What's the solution here ?
>>>
>>> Cheers
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>> --
>> Saeed Iqbal
>> Independant Consultant
>> J2EE - Application Architect / Developer
>>
>
> ---------------------------------------------------------------------
> 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: Struts 2.1.8 with Spring Web Flow plugin

Posted by Celinio Fernandes <ce...@yahoo.com>.
thanks for the info. I will not be wasting my time trying to use it then.

--- On Fri, 12/25/09, Musachy Barroso <mu...@gmail.com> wrote:

From: Musachy Barroso <mu...@gmail.com>
Subject: Re: Struts 2.1.8 with Spring Web Flow plugin
To: "Struts Users Mailing List" <us...@struts.apache.org>
Date: Friday, December 25, 2009, 12:58 PM

It needs to be fixed to work with SWF 2.

musachy

On Fri, Dec 25, 2009 at 11:54 AM, Celinio Fernandes <ce...@yahoo.com> wrote:
> Hi,
> does anyone know a tutorial or an example about Struts 2 with the Spring Web Flow plugin ?
> There is this one :
> http://cwiki.apache.org/S2PLUGINS/spring-webflow-plugin.html
>
> But it's kind of old and not very informative.
>
> What is the status of that Spring Web Flow plugin in Struts 2.1.8 ?
>
> Thanks.
>
>
>
>
>
>
>

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




      

Re: Struts 2.1.8 with Spring Web Flow plugin

Posted by Musachy Barroso <mu...@gmail.com>.
It needs to be fixed to work with SWF 2.

musachy

On Fri, Dec 25, 2009 at 11:54 AM, Celinio Fernandes <ce...@yahoo.com> wrote:
> Hi,
> does anyone know a tutorial or an example about Struts 2 with the Spring Web Flow plugin ?
> There is this one :
> http://cwiki.apache.org/S2PLUGINS/spring-webflow-plugin.html
>
> But it's kind of old and not very informative.
>
> What is the status of that Spring Web Flow plugin in Struts 2.1.8 ?
>
> Thanks.
>
>
>
>
>
>
>

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


Struts 2.1.8 with Spring Web Flow plugin

Posted by Celinio Fernandes <ce...@yahoo.com>.
Hi,
does anyone know a tutorial or an example about Struts 2 with the Spring Web Flow plugin ?
There is this one : 
http://cwiki.apache.org/S2PLUGINS/spring-webflow-plugin.html

But it's kind of old and not very informative.

What is the status of that Spring Web Flow plugin in Struts 2.1.8 ?

Thanks.






      

Re: how to access struts2 propery from jsp or vice versa

Posted by Gabriel Belingueres <be...@gmail.com>.
something like this?

<result name="someRedirectResult" type="redirect">
  http://www.blahblah.com/something?param1=${value1}&param2=${value2}
</result>

Here, value1 and value2 are searched in the value stack (usually your
action object is at the top of the stack).

2009/12/24 Wes Wannemacher <we...@wantii.com>:
> There is an http header result type and two redirect result types that
> are much better suited for this. You can use properties in the
> struts.xml file as params for the result. I am on my phone, but
> perhaps someone else can post an example.
>
> -W
>
> On 12/24/09, Parm Lehal <pl...@lehal.net> wrote:
>> Hello,
>>
>> I am stuck in trying to access some variables from value stack in jsp
>> page. Is there anyway to do it easily?
>> Is there anyway to communicate with a bean defined in jsp with
>> <jsp:useBean  tag from struts2?  I can access values in struts but not
>> from jsp side. ..Basically I am trying to do something similar to
>>
>> <%
>>
>> response.sendRedirect(..........url based on....<s:property
>> value="%{GRTGRTGT}"/>  .....);
>>
>>
>> Please, tell me if and how can I accomplish something like this.
>>
>>
>>
>> Regards,
>>
>> Parminder Lehal
>>
>>
>>
>> ________________________________________________________________________
>>
>>
>> -----Original Message-----
>> From: Wes Wannemacher <we...@wantii.com>
>> Reply-to: "Struts Users Mailing List" <us...@struts.apache.org>
>> To: Struts Users Mailing List <us...@struts.apache.org>
>> Subject: Re: if tag with #parameters
>> Date: Wed, 23 Dec 2009 09:35:59 -0500
>>
>>
>> I have used a similar construct quite a bit, but normally, I refer to
>> parameters like this -
>>
>> <s:if test="%{#parameters['view'] != null}">
>> view
>> </s:if>
>> <s:else>
>> not view
>> </s:else>
>>
>> In cases like this, I just want to affect the way a view is rendered.
>> So, leaving the getter/setter off of the action is the way to go.
>>
>> -Wes
>>
>> On Tue, Dec 22, 2009 at 6:05 AM, foo bar <li...@gmail.com> wrote:
>>> Hi,
>>>
>>> I would prefer not to use getter/setter.
>>> What I really want to know is, why is this not working as expected ?
>>>
>>> Anyway, I solved it
>>>
>>> <s:if test="#parameters.messageKey[0] == 'yes'">
>>>
>>> #parameters.messageKey is of type String[], which make sense now
>>>
>>>
>>> On Tue, Dec 22, 2009 at 9:46 PM, Saeed Iqbal <sa...@gmail.com> wrote:
>>>> If it is a request parameter, then make a setter for it to get set and
>>>> getter to retrieve it and use % instead of #
>>>>
>>>> If you want to have the parameter in the page context use the s:set with
>>>> id
>>>>
>>>>
>>>>
>>>> On Tue, Dec 22, 2009 at 3:36 PM, foo bar <li...@gmail.com> wrote:
>>>>
>>>>> Hi all,
>>>>>
>>>>> I'm testing for the existence of a request parameter in a jsp page in
>>>>> Struts 2
>>>>>
>>>>> <%@ taglib prefix="s" uri="/struts-tags"%>
>>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
>>>>> "http://www.w3.org/TR/html4/strict.dtd">
>>>>> <s:property value="#parameters.messageKey"/><br/>
>>>>> <s:if test="%{#parameters.messageKey == 'yes'}">
>>>>> yes
>>>>> </s:if>
>>>>> <s:else>
>>>>> no
>>>>> </s:else>
>>>>>
>>>>> But, whatever I do, result is always "no"
>>>>>
>>>>> Tested with these cases:
>>>>>
>>>>> test.jsp
>>>>> test.jsp?messageKey=
>>>>> test.jsp?messageKey=yes
>>>>> test.jsp?messageKey=no
>>>>>
>>>>> Changed it to <s:if test="#parameters.messageKey == 'yes'">, same
>>>>> results
>>>>> Changed it to <s:if test="{#parameters.messageKey == 'yes'}">, results
>>>>> are negated as above, ie you got "no" when previously you got "yes"
>>>>>
>>>>> What's the solution here ?
>>>>>
>>>>> Cheers
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>>
>>>>>
>>>>
>>>>
>>>> --
>>>> Saeed Iqbal
>>>> Independant Consultant
>>>> J2EE - Application Architect / Developer
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>>
>>
>
>
> --
> 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
>
>

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


Re: how to access struts2 propery from jsp or vice versa

Posted by Wes Wannemacher <we...@wantii.com>.
There is an http header result type and two redirect result types that
are much better suited for this. You can use properties in the
struts.xml file as params for the result. I am on my phone, but
perhaps someone else can post an example.

-W

On 12/24/09, Parm Lehal <pl...@lehal.net> wrote:
> Hello,
>
> I am stuck in trying to access some variables from value stack in jsp
> page. Is there anyway to do it easily?
> Is there anyway to communicate with a bean defined in jsp with
> <jsp:useBean  tag from struts2?  I can access values in struts but not
> from jsp side. ..Basically I am trying to do something similar to
>
> <%
>
> response.sendRedirect(..........url based on....<s:property
> value="%{GRTGRTGT}"/>  .....);
>
>
> Please, tell me if and how can I accomplish something like this.
>
>
>
> Regards,
>
> Parminder Lehal
>
>
>
> ________________________________________________________________________
>
>
> -----Original Message-----
> From: Wes Wannemacher <we...@wantii.com>
> Reply-to: "Struts Users Mailing List" <us...@struts.apache.org>
> To: Struts Users Mailing List <us...@struts.apache.org>
> Subject: Re: if tag with #parameters
> Date: Wed, 23 Dec 2009 09:35:59 -0500
>
>
> I have used a similar construct quite a bit, but normally, I refer to
> parameters like this -
>
> <s:if test="%{#parameters['view'] != null}">
> view
> </s:if>
> <s:else>
> not view
> </s:else>
>
> In cases like this, I just want to affect the way a view is rendered.
> So, leaving the getter/setter off of the action is the way to go.
>
> -Wes
>
> On Tue, Dec 22, 2009 at 6:05 AM, foo bar <li...@gmail.com> wrote:
>> Hi,
>>
>> I would prefer not to use getter/setter.
>> What I really want to know is, why is this not working as expected ?
>>
>> Anyway, I solved it
>>
>> <s:if test="#parameters.messageKey[0] == 'yes'">
>>
>> #parameters.messageKey is of type String[], which make sense now
>>
>>
>> On Tue, Dec 22, 2009 at 9:46 PM, Saeed Iqbal <sa...@gmail.com> wrote:
>>> If it is a request parameter, then make a setter for it to get set and
>>> getter to retrieve it and use % instead of #
>>>
>>> If you want to have the parameter in the page context use the s:set with
>>> id
>>>
>>>
>>>
>>> On Tue, Dec 22, 2009 at 3:36 PM, foo bar <li...@gmail.com> wrote:
>>>
>>>> Hi all,
>>>>
>>>> I'm testing for the existence of a request parameter in a jsp page in
>>>> Struts 2
>>>>
>>>> <%@ taglib prefix="s" uri="/struts-tags"%>
>>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
>>>> "http://www.w3.org/TR/html4/strict.dtd">
>>>> <s:property value="#parameters.messageKey"/><br/>
>>>> <s:if test="%{#parameters.messageKey == 'yes'}">
>>>> yes
>>>> </s:if>
>>>> <s:else>
>>>> no
>>>> </s:else>
>>>>
>>>> But, whatever I do, result is always "no"
>>>>
>>>> Tested with these cases:
>>>>
>>>> test.jsp
>>>> test.jsp?messageKey=
>>>> test.jsp?messageKey=yes
>>>> test.jsp?messageKey=no
>>>>
>>>> Changed it to <s:if test="#parameters.messageKey == 'yes'">, same
>>>> results
>>>> Changed it to <s:if test="{#parameters.messageKey == 'yes'}">, results
>>>> are negated as above, ie you got "no" when previously you got "yes"
>>>>
>>>> What's the solution here ?
>>>>
>>>> Cheers
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>>> For additional commands, e-mail: user-help@struts.apache.org
>>>>
>>>>
>>>
>>>
>>> --
>>> Saeed Iqbal
>>> Independant Consultant
>>> J2EE - Application Architect / Developer
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
>
>


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


how to access struts2 propery from jsp or vice versa

Posted by Parm Lehal <pl...@lehal.net>.
Hello,

I am stuck in trying to access some variables from value stack in jsp
page. Is there anyway to do it easily? 
Is there anyway to communicate with a bean defined in jsp with
<jsp:useBean  tag from struts2?  I can access values in struts but not
from jsp side. ..Basically I am trying to do something similar to 

<%

response.sendRedirect(..........url based on....<s:property
value="%{GRTGRTGT}"/>  .....);


Please, tell me if and how can I accomplish something like this.



Regards,

Parminder Lehal



________________________________________________________________________


-----Original Message-----
From: Wes Wannemacher <we...@wantii.com>
Reply-to: "Struts Users Mailing List" <us...@struts.apache.org>
To: Struts Users Mailing List <us...@struts.apache.org>
Subject: Re: if tag with #parameters
Date: Wed, 23 Dec 2009 09:35:59 -0500


I have used a similar construct quite a bit, but normally, I refer to
parameters like this -

<s:if test="%{#parameters['view'] != null}">
view
</s:if>
<s:else>
not view
</s:else>

In cases like this, I just want to affect the way a view is rendered.
So, leaving the getter/setter off of the action is the way to go.

-Wes

On Tue, Dec 22, 2009 at 6:05 AM, foo bar <li...@gmail.com> wrote:
> Hi,
>
> I would prefer not to use getter/setter.
> What I really want to know is, why is this not working as expected ?
>
> Anyway, I solved it
>
> <s:if test="#parameters.messageKey[0] == 'yes'">
>
> #parameters.messageKey is of type String[], which make sense now
>
>
> On Tue, Dec 22, 2009 at 9:46 PM, Saeed Iqbal <sa...@gmail.com> wrote:
>> If it is a request parameter, then make a setter for it to get set and
>> getter to retrieve it and use % instead of #
>>
>> If you want to have the parameter in the page context use the s:set with id
>>
>>
>>
>> On Tue, Dec 22, 2009 at 3:36 PM, foo bar <li...@gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I'm testing for the existence of a request parameter in a jsp page in
>>> Struts 2
>>>
>>> <%@ taglib prefix="s" uri="/struts-tags"%>
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
>>> "http://www.w3.org/TR/html4/strict.dtd">
>>> <s:property value="#parameters.messageKey"/><br/>
>>> <s:if test="%{#parameters.messageKey == 'yes'}">
>>> yes
>>> </s:if>
>>> <s:else>
>>> no
>>> </s:else>
>>>
>>> But, whatever I do, result is always "no"
>>>
>>> Tested with these cases:
>>>
>>> test.jsp
>>> test.jsp?messageKey=
>>> test.jsp?messageKey=yes
>>> test.jsp?messageKey=no
>>>
>>> Changed it to <s:if test="#parameters.messageKey == 'yes'">, same results
>>> Changed it to <s:if test="{#parameters.messageKey == 'yes'}">, results
>>> are negated as above, ie you got "no" when previously you got "yes"
>>>
>>> What's the solution here ?
>>>
>>> Cheers
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>> --
>> Saeed Iqbal
>> Independant Consultant
>> J2EE - Application Architect / Developer
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>




Re: if tag with #parameters

Posted by Wes Wannemacher <we...@wantii.com>.
I have used a similar construct quite a bit, but normally, I refer to
parameters like this -

<s:if test="%{#parameters['view'] != null}">
view
</s:if>
<s:else>
not view
</s:else>

In cases like this, I just want to affect the way a view is rendered.
So, leaving the getter/setter off of the action is the way to go.

-Wes

On Tue, Dec 22, 2009 at 6:05 AM, foo bar <li...@gmail.com> wrote:
> Hi,
>
> I would prefer not to use getter/setter.
> What I really want to know is, why is this not working as expected ?
>
> Anyway, I solved it
>
> <s:if test="#parameters.messageKey[0] == 'yes'">
>
> #parameters.messageKey is of type String[], which make sense now
>
>
> On Tue, Dec 22, 2009 at 9:46 PM, Saeed Iqbal <sa...@gmail.com> wrote:
>> If it is a request parameter, then make a setter for it to get set and
>> getter to retrieve it and use % instead of #
>>
>> If you want to have the parameter in the page context use the s:set with id
>>
>>
>>
>> On Tue, Dec 22, 2009 at 3:36 PM, foo bar <li...@gmail.com> wrote:
>>
>>> Hi all,
>>>
>>> I'm testing for the existence of a request parameter in a jsp page in
>>> Struts 2
>>>
>>> <%@ taglib prefix="s" uri="/struts-tags"%>
>>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
>>> "http://www.w3.org/TR/html4/strict.dtd">
>>> <s:property value="#parameters.messageKey"/><br/>
>>> <s:if test="%{#parameters.messageKey == 'yes'}">
>>> yes
>>> </s:if>
>>> <s:else>
>>> no
>>> </s:else>
>>>
>>> But, whatever I do, result is always "no"
>>>
>>> Tested with these cases:
>>>
>>> test.jsp
>>> test.jsp?messageKey=
>>> test.jsp?messageKey=yes
>>> test.jsp?messageKey=no
>>>
>>> Changed it to <s:if test="#parameters.messageKey == 'yes'">, same results
>>> Changed it to <s:if test="{#parameters.messageKey == 'yes'}">, results
>>> are negated as above, ie you got "no" when previously you got "yes"
>>>
>>> What's the solution here ?
>>>
>>> Cheers
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>
>>
>> --
>> Saeed Iqbal
>> Independant Consultant
>> J2EE - Application Architect / Developer
>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>



-- 
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: if tag with #parameters

Posted by foo bar <li...@gmail.com>.
Hi,

I would prefer not to use getter/setter.
What I really want to know is, why is this not working as expected ?

Anyway, I solved it

<s:if test="#parameters.messageKey[0] == 'yes'">

#parameters.messageKey is of type String[], which make sense now


On Tue, Dec 22, 2009 at 9:46 PM, Saeed Iqbal <sa...@gmail.com> wrote:
> If it is a request parameter, then make a setter for it to get set and
> getter to retrieve it and use % instead of #
>
> If you want to have the parameter in the page context use the s:set with id
>
>
>
> On Tue, Dec 22, 2009 at 3:36 PM, foo bar <li...@gmail.com> wrote:
>
>> Hi all,
>>
>> I'm testing for the existence of a request parameter in a jsp page in
>> Struts 2
>>
>> <%@ taglib prefix="s" uri="/struts-tags"%>
>> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
>> "http://www.w3.org/TR/html4/strict.dtd">
>> <s:property value="#parameters.messageKey"/><br/>
>> <s:if test="%{#parameters.messageKey == 'yes'}">
>> yes
>> </s:if>
>> <s:else>
>> no
>> </s:else>
>>
>> But, whatever I do, result is always "no"
>>
>> Tested with these cases:
>>
>> test.jsp
>> test.jsp?messageKey=
>> test.jsp?messageKey=yes
>> test.jsp?messageKey=no
>>
>> Changed it to <s:if test="#parameters.messageKey == 'yes'">, same results
>> Changed it to <s:if test="{#parameters.messageKey == 'yes'}">, results
>> are negated as above, ie you got "no" when previously you got "yes"
>>
>> What's the solution here ?
>>
>> Cheers
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>
>
>
> --
> Saeed Iqbal
> Independant Consultant
> J2EE - Application Architect / Developer
>

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


Re: if tag with #parameters

Posted by Saeed Iqbal <sa...@gmail.com>.
If it is a request parameter, then make a setter for it to get set and
getter to retrieve it and use % instead of #

If you want to have the parameter in the page context use the s:set with id



On Tue, Dec 22, 2009 at 3:36 PM, foo bar <li...@gmail.com> wrote:

> Hi all,
>
> I'm testing for the existence of a request parameter in a jsp page in
> Struts 2
>
> <%@ taglib prefix="s" uri="/struts-tags"%>
> <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"
> "http://www.w3.org/TR/html4/strict.dtd">
> <s:property value="#parameters.messageKey"/><br/>
> <s:if test="%{#parameters.messageKey == 'yes'}">
> yes
> </s:if>
> <s:else>
> no
> </s:else>
>
> But, whatever I do, result is always "no"
>
> Tested with these cases:
>
> test.jsp
> test.jsp?messageKey=
> test.jsp?messageKey=yes
> test.jsp?messageKey=no
>
> Changed it to <s:if test="#parameters.messageKey == 'yes'">, same results
> Changed it to <s:if test="{#parameters.messageKey == 'yes'}">, results
> are negated as above, ie you got "no" when previously you got "yes"
>
> What's the solution here ?
>
> Cheers
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>


-- 
Saeed Iqbal
Independant Consultant
J2EE - Application Architect / Developer