I've encontered the same problem and it took me a while to figure it out
why.

So maybe it's a good idea to make it automatic on the framework,

On all TextField<E> constructors without the type parameter we should call
setType() like this:

setType((Class<?>) ((ParameterizedType)
getClass().getGenericSuperclass()).getActualTypeArguments()[0]);

Too complicated??



On Fri, Jul 23, 2010 at 1:02 AM, Josh Glassman [via Apache Wicket] <
ml-node+2299461-894925024-293...@n4.nabble.com<ml-node%2b2299461-894925024-293...@n4.nabble.com>
> wrote:

> There is also a constructor that will take a Class type as a parameter.
>
> On Thu, Jul 22, 2010 at 3:11 PM, T Ames <[hidden 
> email]<http://user/SendEmail.jtp?type=node&node=2299461&i=0>>
> wrote:
>
> > I think you have to use the setType(Integer.class) method on the
> TextField
> > object.
> >
> > setType
> >
> > public final FormComponent
> >
> >
> <file:///C:/Downloads/Java/wicket/apache-wicket-1.4.1/apidocs/org/apache/wicket/markup/html/form/FormComponent.html><T
>
> >
> >
> <file:///C:/Downloads/Java/wicket/apache-wicket-1.4.1/apidocs/org/apache/wicket/markup/html/form/FormComponent.html>>
>
> > *setType*(java.lang.Class<?> type)
> >
> > Sets the type that will be used when updating the model for this
> component.
> > If no type is specified String type is assumed.
> >
> >  *Parameters:*type - *Returns:*this for chaining
> >
> > On Thu, Jul 22, 2010 at 1:50 PM, Douglas Ferguson <
> > [hidden email] <http://user/SendEmail.jtp?type=node&node=2299461&i=1>>
> wrote:
> >
> > > Has anybody succesfully used TextField<Integer>?
> > >
> > > I get an runtime exception trying to cast String to Integer.
> > >
> > > If supply (Integer.class) to the constructor then it is trying to case
> > Long
> > > to Integer.
> > >
> > > D/
> > >
> >
>
>
> ------------------------------
>  View message @
> http://apache-wicket.1842946.n4.nabble.com/TextField-Integer-tp2299053p2299461.html
> To start a new topic under Wicket - User, email
> ml-node+1842947-1647783149-293...@n4.nabble.com<ml-node%2b1842947-1647783149-293...@n4.nabble.com>
> To unsubscribe from Wicket - User, click 
> here<http://apache-wicket.1842946.n4.nabble.com/subscriptions/Unsubscribe.jtp?code=YXZyYWhhbXJAZ21haWwuY29tfDE4NDI5NDd8LTEwNzY0NzQ1ODc=>.
>
>
>


-- 
[]'s
Avraham Rosenzweig
avrah...@gmail.com

-- 
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/TextField-Integer-tp2299053p2299478.html
Sent from the Wicket - User mailing list archive at Nabble.com.

Reply via email to