Hello all,

To facilitate trying out the different generics alternatives
in practice, I prepared a patch 

  
http://people.apache.org/~thrantal/IModel_(and_some_other)_generics_without_Component_generics_poc_with_separate_unsafe_getModel.patch

against trunk where the type argument is removed from
Component, MarkupContainer, Page and many of their
subclasses. 

In the patched version, you have these methods in Component

  public final IModel<?> getModel() 

  /**
   * Warning: returned IModel&lt;T&gt; is not guaranteed to contain T, because 
of runtime type erasure.
   * @see #getModel()
   *
   * @return The model
   */
  public final <T> IModel<T> getTypedModel()

There might have been a couple of workarounds for a javac
bug [1], and I got kind of lost with IConverterLocator and
IConverter, so this most probably needs some love. But the
model handling in Component is the beef here.                                   

The getTypedModel is inspired by the suggestion by Matej [2].

There's a lot of components that were left with generics
here, such as all FormComponents. I'm not saying that this
is how it should be, but hope that you can use the patch to
try out different versions of partially generified Wicket in
practice.

Best wishes,
Timo

[1] http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6302954

[2]                                                                             
http://www.nabble.com/Re%3A-%28Class%3C--extends-Page%3C-%3E%3E%29-casting-troubles-p17378297.html
 

-- 
Timo Rantalaiho           
Reaktor Innovations Oy    <URL: http://www.ri.fi/ >

Reply via email to