If I take out the setType method, still no cast error, but the Integer checking is not done - feedback panel does not receive an error.
On Mon, Jul 26, 2010 at 9:23 AM, T Ames <tamesw...@gmail.com> wrote: > I just whipped up a test, this is working - at least on 1.4.1 > > Form<Void> form = new Form<Void>("form"); > add(form); > > final TextField<Integer> textInt = new > TextField<Integer>("textInt", new Model<Integer>()); > textInt.setType(Integer.class); > form.add(textInt); > > I did not get any errors casting to Long. I even added a feedback > panel and put in alpha characters. It properly came back stated that > ...'abc' is not a valid Integer. > > > > On Mon, Jul 26, 2010 at 1:21 AM, dferguson <doug...@douglasferguson.us> wrote: >> >> When I supply Integer as the type, i get an error cannot cast "Long" to >> "Integer" >> >> D/ >> >> On Jul 22, 2010, at 5:01 PM, Josh Glassman 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 <tamesw...@gmail.com> 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 < >> >> doug...@douglasferguson.us> 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/ >> >>> >> >> >> >> >> --------------------------------------------------------------------- >> 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