0

Autobinding strange behaviour

asked 2011-03-11 10:30:13 +0800

dagarwal82 gravatar image dagarwal82
246 4

Person bean with 2 params -> First Name & Last Name

A listbox is showing all the Persons. I have 2 textbox at the left which are mapped with the 'selectedItem' of the listbox, now If I change the value in the textbox it changes the corresponding grid's columns value. I want to be able to select the row and selected first name and last name to be shown in the textbox but don't want to update the content of the grid if I type in the textbox. how to do this with zkoss.

delete flag offensive retag edit

1 Reply

Sort by ยป oldest newest

answered 2011-03-16 16:30:35 +0800

robertpic71 gravatar image robertpic71
1275 1

It's all live. The object person (i.e. from database) = person in the listbox = person selectItem = person in textbox.

Some ZK options (docs, Zeta wizards)
1. override binding: save-when=none
2. validate the data (component!) in the event "onBindingSave"
3. save bind only i.e. onClick$saveButton

or instead of 2: 4. reload the bean (i.e. database) when the user use the the cancel button

However there are some issues:
at 2)
I don't like check the UI.getValues and i often need more than one input field for complex contraints.
Otherwise without onBindingSave, the bean is updated before validation.

at 4)
Cancel could only done in modal dialogs, otherwise i.e. select another person form listbox, keep the wrong value in the bean

My (personal) best practice:
Variant 1:
1.) override binding: save-when=none
3.) save bind only i.e. onClick$saveButton do validation (with bean)
2+4.) use only modal/highlighted windows for complex updates and handle all cancel/close operation (reload from database)

Variant 2:
1.) load the newest beanvalues from database before change
...

Variant 3:
1.) override binding: save-when=none
2.) use an extra bean for selectedItem
3.) save bind only i.e. onClick$saveButton do validation
4.) copy bean only when all validation is ok
Note: i use Spring beanutils to copy the properties from (live)bean to (UI)bean

Please post in help forum next time.

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: 2011-03-11 10:30:13 +0800

Seen: 1,532 times

Last updated: Mar 16 '11

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