Re: Correct use of RangeValidator
If you are using a map TextField can't determine the type. -Matej On Tue, Mar 17, 2009 at 9:27 PM, Igor Vaynberg wrote: > if you use a propertymodel alongside a formcomponent then yes, but it > is not the generic you declare that is used, it is the model > performing a runtime reflection check on the type of getter/field it > is using. > > -igor > > On Tue, Mar 17, 2009 at 12:08 PM, Adriano dos Santos Fernandes > wrote: >> Igor Vaynberg escreveu: >>> >>> textfield doesnt know that it has been declared as textfield >>> at runtime unless it is an anonymous class. welcome to java generics. >>> lookup type erasure. >> >> Hmm... And what about work done using IObjectClassAwareModel? >> >> It seems to work for me, I never need to pass Integer.class to >> TextType... >> >> >> Adriano >> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Correct use of RangeValidator
if you use a propertymodel alongside a formcomponent then yes, but it is not the generic you declare that is used, it is the model performing a runtime reflection check on the type of getter/field it is using. -igor On Tue, Mar 17, 2009 at 12:08 PM, Adriano dos Santos Fernandes wrote: > Igor Vaynberg escreveu: >> >> textfield doesnt know that it has been declared as textfield >> at runtime unless it is an anonymous class. welcome to java generics. >> lookup type erasure. > > Hmm... And what about work done using IObjectClassAwareModel? > > It seems to work for me, I never need to pass Integer.class to > TextType... > > > Adriano > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Correct use of RangeValidator
Igor Vaynberg escreveu: textfield doesnt know that it has been declared as textfield at runtime unless it is an anonymous class. welcome to java generics. lookup type erasure. Hmm... And what about work done using IObjectClassAwareModel? It seems to work for me, I never need to pass Integer.class to TextType... Adriano - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Correct use of RangeValidator
textfield doesnt know that it has been declared as textfield at runtime unless it is an anonymous class. welcome to java generics. lookup type erasure. -igor On Tue, Mar 17, 2009 at 11:44 AM, Warren Bell wrote: > I thought that I was telling the TextField, by the type , that it's > model object is an integer. And I thought that it would retrieve its value > from the model I set on it's form. > > super(name, new CompoundPropertyModel(valueMap) > > valueMap is an existing ValueMap with a value with key "intField" and that > ValueMap#getAsInteger("intField") would be called. I guess > ValueMap#getString("intField") is being called. Is it the ValueMap that is > messing me up? What am I missing? > > Igor Vaynberg wrote: >> >> to construct a textfield that works with integer you either have to >> pass Integer.class as a constructor arg, or call >> setType(Integer.class); >> >> -igor >> >> On Tue, Mar 17, 2009 at 8:21 AM, Wilhelmsen Tor Iver >> wrote: >> WicketMessage: Exception 'java.lang.ClassCastException: java.lang.Integer' occurred during validation org.apache.wicket.validation.validator.RangeValidator on component 2:body:recvAnalisysForm:intField Root cause:java.lang.ClassCastException: java.lang.Integer at java.lang.String.compareTo(String.java:90) >>> >>> According to the error message, the validator gets a String value here; >>> have you checked the actual IModel used by the field? The default Model >>> for *TextField uses String IIRC... >>> >>> IModel model = new PropertyModel(theBean, "intField"); >>> RequiredTextField intField = new >>> RequiredTextField("intField", model); >>> intField.add(new RangeValidator(0, 100)); >>> >>> - >>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >>> For additional commands, e-mail: users-h...@wicket.apache.org >>> >>> >>> >> >> - >> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org >> For additional commands, e-mail: users-h...@wicket.apache.org >> >> > > > -- > Thanks, > > Warren Bell > 909-645-8864 > warrenbe...@gmail.com > > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Correct use of RangeValidator
I thought that I was telling the TextField, by the type , that it's model object is an integer. And I thought that it would retrieve its value from the model I set on it's form. super(name, new CompoundPropertyModel(valueMap) valueMap is an existing ValueMap with a value with key "intField" and that ValueMap#getAsInteger("intField") would be called. I guess ValueMap#getString("intField") is being called. Is it the ValueMap that is messing me up? What am I missing? Igor Vaynberg wrote: to construct a textfield that works with integer you either have to pass Integer.class as a constructor arg, or call setType(Integer.class); -igor On Tue, Mar 17, 2009 at 8:21 AM, Wilhelmsen Tor Iver wrote: WicketMessage: Exception 'java.lang.ClassCastException: java.lang.Integer' occurred during validation org.apache.wicket.validation.validator.RangeValidator on component 2:body:recvAnalisysForm:intField Root cause:java.lang.ClassCastException: java.lang.Integer at java.lang.String.compareTo(String.java:90) According to the error message, the validator gets a String value here; have you checked the actual IModel used by the field? The default Model for *TextField uses String IIRC... IModel model = new PropertyModel(theBean, "intField"); RequiredTextField intField = new RequiredTextField("intField", model); intField.add(new RangeValidator(0, 100)); - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Thanks, Warren Bell 909-645-8864 warrenbe...@gmail.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Correct use of RangeValidator
to construct a textfield that works with integer you either have to pass Integer.class as a constructor arg, or call setType(Integer.class); -igor On Tue, Mar 17, 2009 at 8:21 AM, Wilhelmsen Tor Iver wrote: >> WicketMessage: Exception 'java.lang.ClassCastException: >> java.lang.Integer' occurred during validation >> org.apache.wicket.validation.validator.RangeValidator on component >> 2:body:recvAnalisysForm:intField Root >> cause:java.lang.ClassCastException: java.lang.Integer at >> java.lang.String.compareTo(String.java:90) > > According to the error message, the validator gets a String value here; > have you checked the actual IModel used by the field? The default Model > for *TextField uses String IIRC... > > IModel model = new PropertyModel(theBean, "intField"); > RequiredTextField intField = new > RequiredTextField("intField", model); > intField.add(new RangeValidator(0, 100)); > > - > To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > For additional commands, e-mail: users-h...@wicket.apache.org > > - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
SV: Correct use of RangeValidator
> WicketMessage: Exception 'java.lang.ClassCastException: > java.lang.Integer' occurred during validation > org.apache.wicket.validation.validator.RangeValidator on component > 2:body:recvAnalisysForm:intField Root > cause:java.lang.ClassCastException: java.lang.Integer at > java.lang.String.compareTo(String.java:90) According to the error message, the validator gets a String value here; have you checked the actual IModel used by the field? The default Model for *TextField uses String IIRC... IModel model = new PropertyModel(theBean, "intField"); RequiredTextField intField = new RequiredTextField("intField", model); intField.add(new RangeValidator(0, 100)); - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Correct use of RangeValidator
I am getting a ClassCastException when using RangeValidator like this: RequiredTextField intField = new RequiredTextField("intField"); intField.add(new RangeValidator(0, 100)); or like this: RequiredTextField intField = new RequiredTextField("intField"); intField.add(new RangeValidator(0, 100)); WicketMessage: Exception 'java.lang.ClassCastException: java.lang.Integer' occurred during validation org.apache.wicket.validation.validator.RangeValidator on component 2:body:recvAnalisysForm:intField Root cause:java.lang.ClassCastException: java.lang.Integer at java.lang.String.compareTo(String.java:90) The example app shows it coded this way, but NumberValidator has been deprecated. add(new RequiredTextField("integerInRangeProperty").add(NumberValidator.range(0, 100))); What is the correct way of using RangeValidator and how do you type it? Warren - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org