Error with int fields, ZK or higher

asked 2019-10-27 11:41:00 +0800

ntsetso gravatar image ntsetso
59 1 4

I have an aplication working correctly with ZK 7.0.3. If I use ZK or higher I get an error triggered by rendering a form with a textbox bound to an int field in a bean.

Tried initialize field with zero but the error persists. Please help solve the problem. TIA.

P.S. I don't include the eclipse console error logs because when I do the post is flagged as spam.

delete flag offensive retag edit


that's unfortunate it's hard to help without any error reproducing information, sometimes it helps to avoid the word 'script' in your post. Even better you can provide a runnable example on http://zkfiddle.org/, and just post the link here.

cor3000 ( 2019-10-28 12:48:32 +0800 )edit

e.g. this example works for me using http://zkfiddle.org/sample/2nfi5qi/1-textbox-bound-to-int maybe you can add what's missing to show the error you encounter

cor3000 ( 2019-10-28 12:59:40 +0800 )edit

2 Answers

Sort by ยป oldest newest most voted

answered 2019-11-11 09:57:10 +0800

cor3000 gravatar image cor3000
6168 2 7
ZK Team

Thanks for the explanations.

In both cases your curCabinet member is NULL.

private Cabinet curCabinet, newCabinet = new Cabinet();

So there's no instance the form-binding can create a proxy object around, and errors are to be expected. The form binding was re-implemented since ZK 8 from hash maps to proxy objects.

If you load and save to the same field, which is the expected usage, your example will work.

form="@id('cab') @load(vm.newCabinet) @save(vm.newCabinet,before='create')">

If you duplicate your objects manually you basically don't need form binding - as you already built your own staging object.

link publish delete flag offensive edit


Thank you very much. I've got the point. Your answer is very clear. I modified the code as suggested and everything already works with ZK 8.

ntsetso ( 2019-11-11 22:38:25 +0800 )edit

:) thanks for letting us know

cor3000 ( 2019-11-12 09:30:42 +0800 )edit

answered 2019-11-03 14:38:50 +0800

ntsetso gravatar image ntsetso
59 1 4

I think I found the cause of the problem: The textbox is bound to an int field of an object that is initially null. With ZK this causes an error. ZK 7.0.3 gives no error.


link publish delete flag offensive edit


I tried again, still I can't see any new error between ZK 7.0.8 and ZK http://zkfiddle.org/sample/2nfi5qi/2-textbox-bound-to-int

in any case good to hear you found the source in your scenario

cor3000 ( 2019-11-04 09:51:41 +0800 )edit

I created this example. http://zkfiddle.org/sample/1k7hj6j/15-cabinete-creation Please change ZK to 8.0.0 or higher to see the error.

ntsetso ( 2019-11-10 00:49:27 +0800 )edit

I slightly modified the example to show another strange behavior when changing to ZK 8.


ntsetso ( 2019-11-10 13:38:48 +0800 )edit

in your first example the value is initially null, so a NullPointerException is not unexpected if you'd ask me. Clearly indicates a programmer's error. What would you expect?

cor3000 ( 2019-11-11 00:02:45 +0800 )edit

in your second example you missed to explain, what is "strange". This would help to focus on the problem. Please always mention what you'd expect to happen as well.

cor3000 ( 2019-11-11 00:04:29 +0800 )edit
Your answer
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




Asked: 2019-10-27 11:41:00 +0800

Seen: 21 times

Last updated: Nov 11 '19

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