You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by "Griffith, Michael *" <Mi...@fda.hhs.gov> on 2009/02/06 20:27:10 UTC

What's the correct expression syntax?

Hi, 
 
I don't think I fully understand OGNL and I need some help with an
expression...
 
I have a param that I am passing to an action.  the parameter is called
selectedType, and it has a getter and setter on the action. It is
getting set correctly. When I try to evaluate the expression using the
<s:if> tag, it never evaluates correctly.  The action parameter is as
follows;
 
./component/new.action?selectedType=C
 
I've tried the following expressions

<s:if test="%{selectedType == 'C'}">
	... Do work
</s:if>

<s:if test="%{#selectedType == 'C'}">
	... Do work
</s:if>

<s:if test="${selectedType == 'C'}">
	... Do work
</s:if>

None of which seem to work.  Can someone clear this up?

Thanks in advance, 

MG

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


RE: What's the correct expression syntax?

Posted by "Griffith, Michael *" <Mi...@fda.hhs.gov>.
Ah, thanks for the reply and to Richard as well. It's insane how much
time it is easy to waste on small things like that.
Thanks guys! 

-----Original Message-----
From: Dale Newfield [mailto:dale@newfield.org] 
Sent: Friday, February 06, 2009 1:32 PM
To: Struts Users Mailing List
Subject: Re: What's the correct expression syntax?

Griffith, Michael * wrote:
> <s:if test="%{selectedType == 'C'}">
> 	... Do work
> </s:if>

Is the correct one, except for the one-character-string gotcha:
http://struts.apache.org/2.1.6/docs/why-wont-the-if-tag-evaluate-a-one-c
har-string.html

-Dale

---------------------------------------------------------------------
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: What's the correct expression syntax?

Posted by Dale Newfield <da...@newfield.org>.
Griffith, Michael * wrote:
> <s:if test="%{selectedType == 'C'}">
> 	... Do work
> </s:if>

Is the correct one, except for the one-character-string gotcha:
http://struts.apache.org/2.1.6/docs/why-wont-the-if-tag-evaluate-a-one-char-string.html

-Dale

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


RE: What's the correct expression syntax?

Posted by Richard Gundersen <R....@salford.ac.uk>.
I think it's because you're comparing a single character string, which OGNL treats as a bit of a special case for some reason. 

I dont have my code with me now but I'm pretty sure I had the same problem. Google 'comparing single character string in ognl' for some pointers (sorry, I cant verify myself right now)


-----Original Message-----
From: Griffith, Michael * [mailto:Michael.Griffith@fda.hhs.gov]
Sent: Fri 06/02/2009 19:27
To: Struts Users Mailing List
Subject: What's the correct expression syntax?
 
Hi, 
 
I don't think I fully understand OGNL and I need some help with an
expression...
 
I have a param that I am passing to an action.  the parameter is called
selectedType, and it has a getter and setter on the action. It is
getting set correctly. When I try to evaluate the expression using the
<s:if> tag, it never evaluates correctly.  The action parameter is as
follows;
 
./component/new.action?selectedType=C
 
I've tried the following expressions

<s:if test="%{selectedType == 'C'}">
	... Do work
</s:if>

<s:if test="%{#selectedType == 'C'}">
	... Do work
</s:if>

<s:if test="${selectedType == 'C'}">
	... Do work
</s:if>

None of which seem to work.  Can someone clear this up?

Thanks in advance, 

MG

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