There's an existing bug for this.  I'm not sure how fixable it's going
to be; welcome to the implementation nitty gritty of generic types and
type erasure.  Just cause you don't see the typecasts doesn't mean the
compiler has put them there.

Here's a challenge: what if there was a createWidget() method on your
class.  How would you implement it, to create an instance of the
correct class?  You can't do a new T() (the compiler won't let you,
since it doesn't know what T is).

On 6/25/07, Bill Holloway <[EMAIL PROTECTED]> wrote:
I have a Widget base entity extended by several concrete product
entities.  I have

public class <T extends Widget> EditWidgetPage
{
  ...
  @Persist
  public Long _someWidgetId;

  public T _someWidget;

  // normal setters / getters

  void onActivate (long id)
  {
    _someWidgetId = id;
    _someWidget = _dao.get (id); // gets right subtype of Widget.
Generics. Tested.
  }

  // onPassivate as per usual pattern.

  void onActionFromEditForm ()
  {
    _dao.saveOrUpdate (_someWidget);
  }
}

The page for this just uses a bean edit form, nothing else:
object="someWidget".  The saveOrUpdate call complains that someWidget
is of type Widget rather than the subclass it's instantiated to be.
Any thoughts?

bill

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




--
Howard M. Lewis Ship
TWD Consulting, Inc.
Independent J2EE / Open-Source Java Consultant
Creator and PMC Chair, Apache Tapestry
Creator, Apache HiveMind

Professional Tapestry training, mentoring, support
and project work.  http://howardlewisship.com

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to