-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Found that great exemple : http://www.zkoss.org/zkdemo/listbox/dual_listbox
Copy & pasted the code and after a little cleaning I've a custom component that i can reuse easily on my zul
<duallistbox model="@load(vm.listEntityAvailableForGroup)" chosenDataList="@save(vm.entity.listEntityToAddToGroup)"/>
Now my only issue is what do I need to add to the DualistBox.java file of my component so when the user click on one of the button, on top of moving the item, it also triggers the @save ?
Thanks for your help
Sharing since i found out how to do it.
You gotta use the @ComponentAnnotation annotation like described : http://books.zkoss.org/wiki/ZK_Developer%27s_Reference/MVVM/Advanced/Binding_Annotation_for_a_Custom_Component (http://books.zkoss.org/wiki/ZKDeveloper%27sReference/MVVM/Advanced/BindingAnnotationforaCustom_Component)
In DualListbox, I added the annotation on my getter :
@ComponentAnnotation("@ZKBIND(ACCESS=save, SAVE_EVENT=onChoose)")
public List<String> getChosenDataList() {
return new ArrayList<String>(chosenDataModel);
}
And then you only need to make sure you send the "onChoose" event when you click on the buttons.
Events.postEvent(new ChooseEvent(this, set));
In the ZK exemple it's already the case for the onChoose & unchooseItem methods. So you only need to make it so that the chooseAllItem & unchooseAll also send this event and voilà.
Btw am I right in thinking that in the current use case, there is no use for the data attribut of the ChooseEvent object?
It's just in case someone want to intercept it to see what is getting changed right?
Asked: 2015-06-17 09:46:27 +0800
Seen: 24 times
Last updated: Jun 17 '15
ZK drang and drop and databinding [closed]
Create Crud of a User that has a collection of books
Create a Zk session variable with a menu
Using databinding in menupopup
ZK Clustering, Session Replication Question [closed]
Problem binding values to a composite component
How can i load a constant in .zul
set selectedItem of list in viewmodel - cleaner way? [closed]