You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by "Corbin, James" <jc...@iqnavigator.com> on 2011/06/15 23:20:56 UTC

TextField and Java Number

I am creating an input field that should accept numbers only, so I defined my TextField component as follows,

TextField<Number>(String markupId, IModel<Number> model)

I am "forcing" the model update by adding AjaxFormComponentUpdatingBehavior("onblur")...

The model doesn't appear to be getting updated (works okay if defined as TextField<String>).

I am wondering if the alternate constructor format is required to make it work with types not derived from a String, as in,

TextField<Number>(String markupId, IModel<Number> model, Number.class)  // explicitly specify the type

I thought moving to support generics in wicket eliminated the need for this kind of syntax.

Is specifying the type (e.g., class) the solution,  or do I need to add a specific type converter for type Number???

Thanks,
J.D.

RE: TextField and Java Number

Posted by "Corbin, James" <jc...@iqnavigator.com>.
LOL...good point...so the type Number.class was probably a bad choice :) I'm going with a BigDecimal as my type as that should support all my needs.

Thanks,
J.D.

-----Original Message-----
From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
Sent: Wednesday, June 15, 2011 3:30 PM
To: users@wicket.apache.org
Subject: Re: TextField and Java Number

Number is abstract.  How is TextField supposed to be able to
instantiate one using the text?  You can't use one of the subclasses?

On Wed, Jun 15, 2011 at 5:20 PM, Corbin, James <jc...@iqnavigator.com> wrote:
> I am creating an input field that should accept numbers only, so I defined my TextField component as follows,
>
> TextField<Number>(String markupId, IModel<Number> model)
>
> I am "forcing" the model update by adding AjaxFormComponentUpdatingBehavior("onblur")...
>
> The model doesn't appear to be getting updated (works okay if defined as TextField<String>).
>
> I am wondering if the alternate constructor format is required to make it work with types not derived from a String, as in,
>
> TextField<Number>(String markupId, IModel<Number> model, Number.class)  // explicitly specify the type
>
> I thought moving to support generics in wicket eliminated the need for this kind of syntax.
>
> Is specifying the type (e.g., class) the solution,  or do I need to add a specific type converter for type Number???
>
> Thanks,
> J.D.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


RE: TextField and Java Number

Posted by "Corbin, James" <jc...@iqnavigator.com>.
Good point.  Number is not the appropriate type in this case.  I think I should

-----Original Message-----
From: jcarman@carmanconsulting.com [mailto:jcarman@carmanconsulting.com] On Behalf Of James Carman
Sent: Wednesday, June 15, 2011 3:30 PM
To: users@wicket.apache.org
Subject: Re: TextField and Java Number

Number is abstract.  How is TextField supposed to be able to
instantiate one using the text?  You can't use one of the subclasses?

On Wed, Jun 15, 2011 at 5:20 PM, Corbin, James <jc...@iqnavigator.com> wrote:
> I am creating an input field that should accept numbers only, so I defined my TextField component as follows,
>
> TextField<Number>(String markupId, IModel<Number> model)
>
> I am "forcing" the model update by adding AjaxFormComponentUpdatingBehavior("onblur")...
>
> The model doesn't appear to be getting updated (works okay if defined as TextField<String>).
>
> I am wondering if the alternate constructor format is required to make it work with types not derived from a String, as in,
>
> TextField<Number>(String markupId, IModel<Number> model, Number.class)  // explicitly specify the type
>
> I thought moving to support generics in wicket eliminated the need for this kind of syntax.
>
> Is specifying the type (e.g., class) the solution,  or do I need to add a specific type converter for type Number???
>
> Thanks,
> J.D.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: TextField and Java Number

Posted by James Carman <ja...@carmanconsulting.com>.
Number is abstract.  How is TextField supposed to be able to
instantiate one using the text?  You can't use one of the subclasses?

On Wed, Jun 15, 2011 at 5:20 PM, Corbin, James <jc...@iqnavigator.com> wrote:
> I am creating an input field that should accept numbers only, so I defined my TextField component as follows,
>
> TextField<Number>(String markupId, IModel<Number> model)
>
> I am "forcing" the model update by adding AjaxFormComponentUpdatingBehavior("onblur")...
>
> The model doesn't appear to be getting updated (works okay if defined as TextField<String>).
>
> I am wondering if the alternate constructor format is required to make it work with types not derived from a String, as in,
>
> TextField<Number>(String markupId, IModel<Number> model, Number.class)  // explicitly specify the type
>
> I thought moving to support generics in wicket eliminated the need for this kind of syntax.
>
> Is specifying the type (e.g., class) the solution,  or do I need to add a specific type converter for type Number???
>
> Thanks,
> J.D.
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org