-
FEATURED COMPONENTS
First time here? Check out the FAQ!
I have the following code:
<window apply="org.zkoss.bind.BindComposer" viewModel="@id('vm') @init('test.Index')">
<vlayout>
<combobox id="cmbColor"
model="@load(vm.colors)"
selectedItem="@bind(vm.colorSelected)">
<template name="model">
<comboitem label="@load(each)"/>
</template>
</combobox>
<button label="Show" onClick="@command('show')"/>
<button label="Clear" onClick="@command('clear')"/>
<label value="@load(vm.colorShow)"/>
</vlayout>
and the VM the event:
public class Index {
private List<String> colors;
private String colorSelected;
private String colorShow;
public Index(){
colors = Model.getColors();
}
@Command @NotifyChange(".")
public void show(){
colorShow = "color: "+colorSelected;
}
@Command @NotifyChange(".")
public void clear(){
colorSelected = null;
}
public List<String> getColors() {
return colors;
}
public void setColors(List<String> colors) {
this.colors = colors;
}
public String getColorSelected() {
return colorSelected;
}
public void setColorSelected(String colorSelected) {
this.colorSelected = colorSelected;
}
public String getColorShow() {
return colorShow;
}
public void setColorShow(String colorShow) {
this.colorShow = colorShow;
}
}
When I run the event "clear" the "colorSelected" only updated in the VM but the view shows the last value selected(the selectedItem isn't cleaned).
I wonder should I do to clean one or more comboboxes when running the event of a clean button.
If you will check your this code..
@Command @NotifyChange("*")
public void clear(){
colorSelected = null;
}
you made changes in colorSelected so if you will do NotifyChange("*")
it will Notify only colorSelected not other variables in the clear event fire. And ne more thing i have to mentioned here you have used NotifyChange(".")
it should be NotifyChange("*")
Asked: 2013-05-15 16:08:44 +0800
Seen: 7 times
Last updated: May 16 '13
Problem binding values to a composite component
How to access static member field of a class in zul without zscript
How can i load a constant in .zul
MVVM Validator: class not found ? [closed]
MVVM tab box - delay @load until tab pane displayed?
mvvm, load or save with after or before for seach command
how to fire an event when a variable value loaded through VM
is there any event trigger from zk component on binding ?
ZK team plans to dispose of Composer EventQueues no longer in scope? [closed]