I thought that I was telling the TextField, by the type <Integer>, 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)

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 <[email protected]> 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<Integer> model = new PropertyModel<Integer>(theBean, "intField");
RequiredTextField<Integer> intField = new
RequiredTextField<Integer>("intField", model);
intField.add(new RangeValidator<Integer>(0, 100));

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]



--
Thanks,

Warren Bell
909-645-8864
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to