You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by MN...@tacintel.com on 2004/03/05 22:17:57 UTC

'instanceof'

Is there a way to test 'instanceof' in a macro?

This would be very handy.

Thanks,
Michael

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


Re: 'instanceof'

Posted by Peter Romianowski <an...@gmx.de>.
MNewcomb@tacintel.com wrote:

> Is there a way to test 'instanceof' in a macro?
> 
> This would be very handy.

If you don't care about the concept of MVC then you could do something
like:

#if ($foo.getClass().isAssignableFrom($bar.getClass()))
...
#end

But trust me - you wouldn't want that ;) Nathan's solution is much
better. It is a sign of bad design [ :) ] when you have to use operators
like 'instanceof' in a template.

Regards,
Peter

> Thanks,
> Michael
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
> 
> 

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