You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by red phoenix <ro...@gmail.com> on 2008/02/19 17:09:43 UTC

struts2 s:if and displaytag question

I use Struts2 and displaytag, In testList,there is a abc attribute,it
contains data like "english","france",when abc="english",I want to show
En,else show Eu,my code is follows:

<display:table name="testList" id="element" size="6">
  <display:column property="abc" title="def">
    <s:if test=" #element.abc=='english' ">
        En
   </s:if>
   <s:else>
       Eu
   </s:else>
</display:column>

when I execute code,I find it only shows english or france,I don't know why
it don't show En or Eu.Where wrong with my code?

Any idea will be appreciated!
Thanks

Re: struts2 s:if and displaytag question

Posted by Dave Newton <ne...@yahoo.com>.
The "#element" is syntax meaning there's a named element "element" on the
value stack; do the display tags interact with the S2 value stack?

I'd be more likely to try "${element.abc}" as I would have assumed that the
display tags did things with normal JEE contexts.

Just an idea.

Dave

--- red phoenix <ro...@gmail.com> wrote:

> I use Struts2 and displaytag, In testList,there is a abc attribute,it
> contains data like "english","france",when abc="english",I want to show
> En,else show Eu,my code is follows:
> 
> <display:table name="testList" id="element" size="6">
>   <display:column property="abc" title="def">
>     <s:if test=" #element.abc=='english' ">
>         En
>    </s:if>
>    <s:else>
>        Eu
>    </s:else>
> </display:column>
> 
> when I execute code,I find it only shows english or france,I don't know why
> it don't show En or Eu.Where wrong with my code?
> 
> Any idea will be appreciated!
> Thanks
> 


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


Re: struts2 s:if and displaytag question

Posted by Randy Burgess <RB...@nuvox.com>.
It's because you have the property set on that column. Remove that attribute
and if your condition is found then it will display that text.

I don't think that if statement is correct either. This should look like:
<display:column title="def">
  <s:if test="#attr.element.abc == 'english'">
...

Regards,
Randy Burgess
Sr. Web Applications Developer
Nuvox Communications



> From: red phoenix <ro...@gmail.com>
> Reply-To: Struts Users Mailing List <us...@struts.apache.org>
> Date: Wed, 20 Feb 2008 00:09:43 +0800
> To: Struts Users Mailing List <us...@struts.apache.org>
> Subject: struts2 s:if and displaytag question
> 
> I use Struts2 and displaytag, In testList,there is a abc attribute,it
> contains data like "english","france",when abc="english",I want to show
> En,else show Eu,my code is follows:
> 
> <display:table name="testList" id="element" size="6">
>   <display:column property="abc" title="def">
>     <s:if test=" #element.abc=='english' ">
>         En
>    </s:if>
>    <s:else>
>        Eu
>    </s:else>
> </display:column>
> 
> when I execute code,I find it only shows english or france,I don't know why
> it don't show En or Eu.Where wrong with my code?
> 
> Any idea will be appreciated!
> Thanks



This email and any attachments ("Message") may contain legally privileged and/or confidential information.  If you are not the addressee, or if this Message has been addressed to you in error, you are not authorized to read, copy, or distribute it, and we ask that you please delete it (including all copies) and notify the sender by return email.  Delivery of this Message to any person other than the intended recipient(s) shall not be deemed a waiver of confidentiality and/or a privilege.

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