impossible
there is so such thing as ParameterizedType for the example you give..
if you do:
TextField<Integer> field = new TextField<Integer>();
then at runtime that information isnt there anymore. Its gone. welcome
to type erasure..
I think stuff like that is only there if you do:
class MyTextField extends TextField<Integer>
{
}
but then you can already do that just fine in the constructor
yourself.. (calling setType))
johan
On Fri, Jul 23, 2010 at 00:17, avrahamr <[email protected]> wrote:
>
> 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] <
> [email protected]<ml-node%[email protected]>
>> 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
>> [email protected]<ml-node%[email protected]>
>> To unsubscribe from Wicket - User, click
>> here<http://apache-wicket.1842946.n4.nabble.com/subscriptions/Unsubscribe.jtp?code=YXZyYWhhbXJAZ21haWwuY29tfDE4NDI5NDd8LTEwNzY0NzQ1ODc=>.
>>
>>
>>
>
>
> --
> []'s
> Avraham Rosenzweig
> [email protected]
>
> --
> 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.
>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]