I do something like this:

public static <T> T as(Class<T> type, Object value) {
  if (type.isInstance(value)) { return type.cast(value); }

  return null;
}

public Fruit getFruit() { return as(Fruit.class, article); }

public Vegetable getVegetable { return as(Vegetable.class, article); }

In your template you can then use <t:if test="fruit"> ... </t:if>

On Sun, Oct 21, 2012 at 5:19 PM, o1550762 <o1550...@rtrtr.com> wrote:
> Hi,
> I have two entities which extends entity called Article. Now I call article
> and I want based on what type of object is it to call properties for that
> specific object. How should I get this? Should I use some sort of <t:if
> test="returnWhatTypeIsiT"></t:if> in tml and checking what type it is by
> public Object returnWhatTypeIsiT(Article article)
> {
>  // fruit is declared as Fruit fruit;
>   if(article.equals(fruit)){
>    return fruit;
>  else if(article.equals(vegetable)){
>    return vegetable;
> }
>   else
>    {
>       return null;
>     }
> }
>
> I would like your opinion about this, or some guidance how is best way to
> solve this problem. Thanks in advance.
>
>
>
>
> --
> View this message in context: 
> http://tapestry.1045711.n5.nabble.com/Calling-specific-object-tp5717114.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
> For additional commands, e-mail: users-h...@tapestry.apache.org
>



-- 
Howard M. Lewis Ship

Creator of Apache Tapestry

The source for Tapestry training, mentoring and support. Contact me to
learn how I can get you up and productive in Tapestry fast!

(971) 678-5210
http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org
For additional commands, e-mail: users-h...@tapestry.apache.org

Reply via email to