0

Inputbox & Decimalbox & ... behaviour for empty value - FYI

asked 2012-08-28 09:15:37 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

Hy guys,
since I spent some time to debug a complex page just to find out it was a really minor issue (I left a value empty), I took some time to check....
The following empty values returns different error messages:

<intbox value=""/>
java.lang.NumberFormatException: For input string: ""

<longbox value=""/>
java.lang.NumberFormatException: For input string: ""

<decimalbox value=""/>
java.lang.NumberFormatException

<doublebox value=""/>
java.lang.ClassCastException: Unable to find a setter named value that supports

and I could not find anywhere in the documentation that value MUST be specified.

FYI,
be well
Stefano

delete flag offensive retag edit

3 Replies

Sort by ยป oldest newest

answered 2012-08-30 01:47:57 +0800

paowang gravatar image paowang
140 6

I think ZK guesses the type of value and try to convert such value to expected type (ie. the property type of the component).
But the empty value has not enough information for guessing. Usually, the type of value will be "String".
Converting "String" to "Integer" (or other numeric types) is illegal in Java.

So, I think that we might not assign "value" property to component if there is no initial value.
For example, just <intbox />.
You can check org.zkoss.lang.Classes.coerce(Class<?>,Object); for more information.

Hope this helps.

link publish delete flag offensive edit

answered 2012-08-30 11:24:31 +0800

Steva77 gravatar image Steva77 flag of Italy
1014 3
http://www.research.softe...

Thanks,
I see the point... although could this cause problems if I set the value dynamically by scripting?

<intbox value="${someObject.uncheckedValue}"/>

Maybe ZK team might also refine a bit the exception message and make it the same for all.

Cheers
S

link publish delete flag offensive edit

answered 2012-08-31 01:13:17 +0800

paowang gravatar image paowang
140 6

If property value is assigned from a expression, the situation will be a little different.
However, the type of someObject.uncheckedValue normally is same as the type of component's property.
The value doesn't need casting, so, it should be fine,

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2012-08-28 09:15:37 +0800

Seen: 134 times

Last updated: Aug 31 '12

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More