You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Johannes Geppert <jo...@web.de> on 2008/12/05 10:04:50 UTC

OGNL and instanceof

Hello,

i want to iterate above an List with different Objects.
How can i use instanceof to differ the Object.

I try it this way:

<s:iterate value="result" var="object">
 <s:if test="%{ object instanceof my.package.MyClassOne }">
    do something with Class One
 </s:if>
 <s:elseif test="%{ object instanceof my.package.MyClassTwo }">
    do something with Class Two
 </s:elseif>
 <s:else>
   It does not work!
 </else>
</s:iterate>

But it does not work. It runs evertime in the else branch.

Have anyone an Idee?

Best Regards
Johannes Geppert
-- 
View this message in context: http://www.nabble.com/OGNL-and-instanceof-tp20850061p20850061.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: OGNL and instanceof

Posted by Johannes Geppert <jo...@web.de>.


newton.dave wrote:
> 
> I'd try #object first, since it's a named context variable created on the
> page.
> 
> Dave
> 

thank you, this works great.
-- 
View this message in context: http://www.nabble.com/OGNL-and-instanceof-tp20850061p20858557.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: OGNL and instanceof

Posted by Dave Newton <ne...@yahoo.com>.
--- On Fri, 12/5/08, Johannes Geppert wrote:
> i want to iterate above an List with different Objects.
> How can i use instanceof to differ the Object.
> [...]
>  <s:if test="%{ object instanceof my.package.MyClassOne }">

I'd try #object first, since it's a named context variable created on the page.

Dave


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