0

I wonder should I do to clean one or more comboboxes when running the event of a clean button. [closed]

asked 2013-05-15 16:08:44 +0800

guidoguillenroman gravatar image guidoguillenroman
3 1

updated 2013-05-16 07:57:11 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

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.

delete flag offensive retag edit

The question has been closed for the following reason "the question is answered, right answer was accepted" by sjoshi
close date 2013-05-17 10:50:52

1 Answer

Sort by ยป oldest newest most voted
0

answered 2013-05-16 08:08:04 +0800

sjoshi gravatar image sjoshi flag of India
3493 1 8
http://zkframeworkhint.bl...

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("*")

link publish delete flag offensive edit

Question tools

Follow
1 follower

RSS

Stats

Asked: 2013-05-15 16:08:44 +0800

Seen: 7 times

Last updated: May 16 '13

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