struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Wes Wannemacher <w...@wantii.com>
Subject Re: if tag with #parameters
Date Wed, 23 Dec 2009 14:35:59 GMT
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 <linutrix@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 <saeedcs@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 <linutrix@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


Mime
View raw message