You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by RogerV <ro...@googlemail.com> on 2010/03/31 11:49:40 UTC

s:if tag syntax help needed

Hi

I'm iterating over a List<Element> with <s:iterator status="status"
value="structure.elements"> and I want to test that the element returned is
an instanceof a specific type of element, so I've tried with

<s:if test="%{<s:property/> instanceof StringElement}"> 
<s:if test="%{structure.elements[#status.index] instanceof StringElement}">
<s:if test="structure.elements[%{#status.index}] instanceof StringElement}">

none of which work. Could some kind soul show me the correct syntax for
this?

Regards

-- 
View this message in context: http://old.nabble.com/s%3Aif-tag-syntax-help-needed-tp28093648p28093648.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: s:if tag syntax help needed

Posted by RogerV <ro...@googlemail.com>.


DNewfield wrote:
> 
> Felipe A. Lorenz wrote:
>> Im not sure that you can use it (instanceof).
> 
> The problem might not be with instanceof but rather StringElement.  Did 
> you try a fully qualified classname?
> 
> 

Sorry about the delay in replying, but it's a 6 day Easter break in my
locale. Anyway, using the fully qualified class name solves the issue;

<s:if test="%{#element instanceof com.myapp.mypackage.StringElement}">

Regards
-- 
View this message in context: http://old.nabble.com/s%3Aif-tag-syntax-help-needed-tp28093648p28165320.html
Sent from the Struts - User mailing list archive at Nabble.com.


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


Re: s:if tag syntax help needed

Posted by Dale Newfield <da...@newfield.org>.
Felipe A. Lorenz wrote:
> Im not sure that you can use it (instanceof).

The problem might not be with instanceof but rather StringElement.  Did 
you try a fully qualified classname?

> On 31/3/2010 06:49, RogerV wrote:
>> <s:if test="%{structure.elements[#status.index] instanceof 
>> StringElement}">

is the closest you listed.  Try that one (or replace 
"structure.elements[#status.index]" with "top") but with both package 
and classname for StringElement.

-Dale

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


Re: s:if tag syntax help needed

Posted by "Felipe A. Lorenz" <fe...@gmail.com>.
Im not sure that you can use it (instanceof).

Why dont you do that in the action class, creating a new collection!



On 31/3/2010 06:49, RogerV wrote:
> Hi
>
> I'm iterating over a List<Element>  with<s:iterator status="status"
> value="structure.elements">  and I want to test that the element returned is
> an instanceof a specific type of element, so I've tried with
>
> <s:if test="%{<s:property/>  instanceof StringElement}">
> <s:if test="%{structure.elements[#status.index] instanceof StringElement}">
> <s:if test="structure.elements[%{#status.index}] instanceof StringElement}">
>
> none of which work. Could some kind soul show me the correct syntax for
> this?
>
> Regards
>
>