MinimumValidator and Long problem
I have TextField that should take Long value, but on submit it does not really work... org.apache.wicket.RequestCycle logRuntimeException: Exception 'java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long' occurred during validation org.apache.wicket.validation.validator.MinimumValidator on component 10:workForm:hire_worker_1 org.apache.wicket.WicketRuntimeException: Exception 'java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long' occurred during validation org.apache.wicket.validation.validator.MinimumValidator on component 10:workForm:hire_worker_1 My code looks like that: public Work() { add(new FeedbackPanel(errorMsg)); FormString workForm = new FormString(workForm, new ModelString()) { private TextFieldLong hire_worker_1 = new TextFieldLong(hire_worker_1, new ModelLong()); ... { ... add(hire_worker_1.add(new MinimumValidator(0)) .setType(Long.class)); ... } @Override public void onSubmit() { long hiring_worker_1 = hire_worker_1.getModelObject(); ... } }; add(workForm); } Eclipse does like new MinimumValidatorLong(0), so what's the solution for my problem? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992468.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: MinimumValidator and Long problem
Since your model doesn't actually know what type of field it is operating on (like PropertyModel does), you need to call setType(Long.class) on your text field. On Tue, Oct 12, 2010 at 1:23 PM, Zeldor pgronkiew...@gmail.com wrote: I have TextField that should take Long value, but on submit it does not really work... org.apache.wicket.RequestCycle logRuntimeException: Exception 'java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long' occurred during validation org.apache.wicket.validation.validator.MinimumValidator on component 10:workForm:hire_worker_1 org.apache.wicket.WicketRuntimeException: Exception 'java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long' occurred during validation org.apache.wicket.validation.validator.MinimumValidator on component 10:workForm:hire_worker_1 My code looks like that: public Work() { add(new FeedbackPanel(errorMsg)); FormString workForm = new FormString(workForm, new ModelString()) { private TextFieldLong hire_worker_1 = new TextFieldLong(hire_worker_1, new ModelLong()); ... { ... add(hire_worker_1.add(new MinimumValidator(0)) .setType(Long.class)); ... } @Override public void onSubmit() { long hiring_worker_1 = hire_worker_1.getModelObject(); ... } }; add(workForm); } Eclipse does like new MinimumValidatorLong(0), so what's the solution for my problem? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992468.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org -- Jeremy Thomerson http://www.wickettraining.com
Re: MinimumValidator and Long problem
Changing it to : private TextFieldLong hire_worker_1 = new TextFieldLong(hire_worker_1, new ModelLong()); { hire_worker_1.setType(Long.class); } Does not change anything. And is it normal that Eclipse does not let me add anything without enclosing in { }? BTW, is there any easy way to convert nulls to 0 when you submit empty TextFields? On Tue, Oct 12, 2010 at 11:31 PM, jer...@wickettraining.com [via Apache Wicket] ml-node+2992772-1878280583-152...@n4.nabble.comml-node%2b2992772-1878280583-152...@n4.nabble.com wrote: Since your model doesn't actually know what type of field it is operating on (like PropertyModel does), you need to call setType(Long.class) on your text field. On Tue, Oct 12, 2010 at 1:23 PM, Zeldor [hidden email]http://user/SendEmail.jtp?type=nodenode=2992772i=0 wrote: I have TextField that should take Long value, but on submit it does not really work... org.apache.wicket.RequestCycle logRuntimeException: Exception 'java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long' occurred during validation org.apache.wicket.validation.validator.MinimumValidator on component 10:workForm:hire_worker_1 org.apache.wicket.WicketRuntimeException: Exception 'java.lang.ClassCastException: java.lang.Integer cannot be cast to java.lang.Long' occurred during validation org.apache.wicket.validation.validator.MinimumValidator on component 10:workForm:hire_worker_1 My code looks like that: public Work() { add(new FeedbackPanel(errorMsg)); FormString workForm = new FormString(workForm, new ModelString()) { private TextFieldLong hire_worker_1 = new TextFieldLong(hire_worker_1, new ModelLong()); ... { ... add(hire_worker_1.add(new MinimumValidator(0)) .setType(Long.class)); ... } @Override public void onSubmit() { long hiring_worker_1 = hire_worker_1.getModelObject(); ... } }; add(workForm); } Eclipse does like new MinimumValidatorLong(0), so what's the solution for my problem? -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992468.htmlhttp://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992468.html?by-user=t Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2992772i=1 For additional commands, e-mail: [hidden email]http://user/SendEmail.jtp?type=nodenode=2992772i=2 -- Jeremy Thomerson http://www.wickettraining.com http://www.wickettraining.com?by-user=t -- View message @ http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992772.html To unsubscribe from MinimumValidator and Long problem, click herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2992468code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwyOTkyNDY4fC0xMTUwMjA4NDM=. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992825.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: MinimumValidator and Long problem
On Tue, Oct 12, 2010 at 5:07 PM, Zeldor pgronkiew...@gmail.com wrote: Changing it to : private TextFieldLong hire_worker_1 = new TextFieldLong(hire_worker_1, new ModelLong()); { hire_worker_1.setType(Long.class); } Does not change anything. And is it normal that Eclipse does not let me add anything without enclosing in { }? Seems like you have a syntax error perhaps a problem with an anonymous inner class. You can use Pastebin to paste entire file and we can attempt to help. BTW, is there any easy way to convert nulls to 0 when you submit empty TextFields? Create an IConverter and override getConverter -- Jeremy Thomerson http://www.wickettraining.com
Re: MinimumValidator and Long problem
its not a syntax problem. you cant have code outside a method unless its in a static {} block. -igor On Tue, Oct 12, 2010 at 3:25 PM, Jeremy Thomerson jer...@wickettraining.com wrote: On Tue, Oct 12, 2010 at 5:07 PM, Zeldor pgronkiew...@gmail.com wrote: Changing it to : private TextFieldLong hire_worker_1 = new TextFieldLong(hire_worker_1, new ModelLong()); { hire_worker_1.setType(Long.class); } Does not change anything. And is it normal that Eclipse does not let me add anything without enclosing in { }? Seems like you have a syntax error perhaps a problem with an anonymous inner class. You can use Pastebin to paste entire file and we can attempt to help. BTW, is there any easy way to convert nulls to 0 when you submit empty TextFields? Create an IConverter and override getConverter -- Jeremy Thomerson http://www.wickettraining.com - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: MinimumValidator and Long problem
On Tue, Oct 12, 2010 at 5:36 PM, Igor Vaynberg igor.vaynb...@gmail.comwrote: its not a syntax problem. you cant have code outside a method unless its in a static {} block. To me, putting code outside a method *is* a syntax problem, typically caused by inexperience with anonymous inner classes, leading to not enough, or too many } -- Jeremy Thomerson http://www.wickettraining.com
Re: MinimumValidator and Long problem
I have nothing else really, just same more of same stuff, only a Form with Labels, TextFields and submit method. Anyway, deprecated NumberValidator.minimum(0) method works without any problems, are there any disadvantages of using that? On Wed, Oct 13, 2010 at 12:43 AM, jer...@wickettraining.com [via Apache Wicket] ml-node+2992859-520586739-152...@n4.nabble.comml-node%2b2992859-520586739-152...@n4.nabble.com wrote: On Tue, Oct 12, 2010 at 5:36 PM, Igor Vaynberg [hidden email]http://user/SendEmail.jtp?type=nodenode=2992859i=0wrote: its not a syntax problem. you cant have code outside a method unless its in a static {} block. To me, putting code outside a method *is* a syntax problem, typically caused by inexperience with anonymous inner classes, leading to not enough, or too many } -- Jeremy Thomerson http://www.wickettraining.com http://www.wickettraining.com?by-user=t -- View message @ http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2992859.html To unsubscribe from MinimumValidator and Long problem, click herehttp://apache-wicket.1842946.n4.nabble.com/template/TplServlet.jtp?tpl=unsubscribe_by_codenode=2992468code=cGdyb25raWV3aWN6QGdtYWlsLmNvbXwyOTkyNDY4fC0xMTUwMjA4NDM=. -- View this message in context: http://apache-wicket.1842946.n4.nabble.com/MinimumValidator-and-Long-problem-tp2992468p2993027.html Sent from the Users forum mailing list archive at Nabble.com. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org