Re: Calling specific object

2012-10-22 Thread o1550762
Thank you mr. Howard. :) It worked exactly how I wanted it to work.



--
View this message in context: 
http://tapestry.1045711.n5.nabble.com/Calling-specific-object-tp5717114p5717130.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



Re: Calling specific object

2012-10-21 Thread Howard Lewis Ship
I do something like this:

public static  T as(Class 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  ... 

On Sun, Oct 21, 2012 at 5:19 PM, o1550762  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  test="returnWhatTypeIsiT"> 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



Calling specific object

2012-10-21 Thread o1550762
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  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