-
FEATURED COMPONENTS
First time here? Check out the FAQ!
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.
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.
Asked: 2011-03-11 10:30:13 +0800
Seen: 1,532 times
Last updated: Mar 16 '11
ZK studio and eclipse outline problem
ZK Package configuration problem
Eclipse Autocomplete not working in ZUL files...
Syntax Error mark ... help me!
Manual Installation of ZK Studio
Can't see button text whilst running simple demo
Adding Vbox to Center layout in Java