Feb 28th, 2007, 10:32 AM
TableFormBuilder, dobule precision?
I'm using a TableFormBuilder to, well, build a form. Now everything works great, except a double field.
formBuilder.add("price"); adds a JTextField, but with only three digits after the dot (say 1.234, instead of 1.2345..). How can I change that?
Mar 1st, 2007, 02:09 AM
Take a look at org.springframework.richclient.form.binding.swing. NumberBinder from spring-rich-sandbox. It uses a BigDecimalTextField that can control number entry and format nicely. There are usage examples in NumberBinder JavaDocs. Configure the binder in your application context, and then add that binder to binder selection strategy.
Mar 1st, 2007, 05:56 AM
ok. Thank you, it worked. But is it also possible for simple types like double (not java.lang.Double)?
Mar 1st, 2007, 12:23 PM
No, I don't think Spring Rich supports binding primitives, as primitives cannot be held in ValueModels. However, if you are using Java 1.5 or later (I do), autoboxing would automatically convert between double and java.lang.Double, for example.
BTW, storing quantities like price in double-typed variables is not a good idea, you'll get problems with rounding. It is better to use BigDecimal for monetary calculations :-)
Nov 21st, 2010, 02:51 AM
how integer goes?
Originally Posted by Kornel
i use tablebinder.add("level") to bind a integer property
then throw a exception "java.lang.InstantiationError: org.springframework.binding.convert.ConversionExec utor"
how can i bind a integer property to a proper component ?