Menu

#1200 Set "save-when" in Listbox selectedItem does not trigger

3.0.7
closed-fixed
nobody
General (233)
5
2008-10-02
2008-10-01
luca
No

Here is code.
[code]
<?xml version="1.0" encoding="UTF-8"?>
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<window xmlns="http://www.zkoss.org/2005/zul"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
title="Test Listbox"
xsi:schemaLocation="http://www.zkoss.org/2005/zul http://www.zkoss.org/2005/zul/zul.xsd "
id="window" width="100%" height="100%">
<zscript>
<![CDATA[
import java.util.*;
class Foo{
String bar,item;

public Foo(){
}

public Foo(String bar,String item){
this.bar = bar;
this.item = item;
}

public void setBar(String s){
bar = s;
}

public String getBar(){
return bar;
}

public void setItem(String s){
item = s;
}

public String getItem(){
return item;
}

public String toString(){
return "bar :" + bar + " item:"+item;
}
}

onSave(Foo foo){
label.setValue(foo.toString());
}
List fooList = new ArrayList();
fooList.add(new Foo("goofy","1"));
fooList.add(new Foo("minny","2"));
fooList.add(new Foo("pluto","3"));

List itemsList = new ArrayList();
itemsList.add("1");
itemsList.add("2");
itemsList.add("3");
itemsList.add("4");
itemsList.add("5");
itemsList.add("6");
itemsList.add("7");
]]>
</zscript>
<listbox id="listbox" model="@{fooList}" height="200px" selectedItem="@{selectedFoo}">
<listhead sizable="true">
<listheader label="bar"/>
<listheader label="item"/>
</listhead>
<listitem self="@{each=str}" value="@{str}">
<listcell label="@{str.bar}"/>
<listcell label="@{str.item}"/>
</listitem>
</listbox>
<textbox id="textboxDesc" value="@{selectedFoo.bar,save-when='saveButton.onClick'}"/>
<listbox model="@{itemsList}" selectedItem="@{selectedFoo.item,save-when='saveButton.onClick'}" mold="select">
<listitem self="@{each=is}" value="@{is}" label="@{is}"></listitem>
</listbox>
<button id="saveButton" label="save" onClick="onSave(listbox.selectedItem.value)"></button>
<label id="label"></label>
</window>
[/code]

Bug description:
1)select an item from the first list.
2)change the value of the second attribute with the second listbox( the one with mold='select')
3)click the save button : now the value of the second attribute should have been changed but it's still the old one. (Bug ?!!!)
4)click again the save button: the value of the second attribute is now the right one.

This problem doesn't occur if on step #2 ,together with the second attribute , you change the first argument too.

Discussion

  • Henri Chen

    Henri Chen - 2008-10-02
    • milestone: --> 3.0.7
    • summary: data binding and listbox selection --> Set "save-when" in Listbox selectedItem does not trigger
     
  • Henri Chen

    Henri Chen - 2008-10-02

    When set other "save-when" event in Listbox selectedItem does not trigger correctly.

    Test Code
    -------------
    <?xml version="1.0" encoding="UTF-8"?>
    <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
    <window id="window" width="100%" height="100%">
    <html>
    <![CDATA[
    <ol>
    <li>select "minny" from the first listbox.</li>
    <li>You shall see the "minny" and "2" appear on the bottom beside "save" button.</li>
    <li>Select the listbox by the "save" button from "2" to "5".</li>
    <li>You shall not see any change in the first listbox.</li>
    <li>Now click the "save" button.</li>
    <li>You shall see on the first listbox the second column of "minny" changes from "2" to "5".</li>
    <li>Done</li>
    </ol>
    ]]>
    </html>
    <zscript>
    <![CDATA[
    class Foo{
    String bar,item;

    public Foo(){
    }

    public Foo(String bar,String item){
    this.bar = bar;
    this.item = item;
    }

    public void setBar(String s){
    bar = s;
    }

    public String getBar(){
    return bar;
    }

    public void setItem(String s){
    item = s;
    }

    public String getItem(){
    return item;
    }

    public String toString(){
    return "bar :" + bar + " item:"+item;
    }
    }

    List fooList = new ArrayList();
    fooList.add(new Foo("goofy","1"));
    fooList.add(new Foo("minny","2"));
    fooList.add(new Foo("pluto","3"));

    List itemsList = new ArrayList();
    itemsList.add("1");
    itemsList.add("2");
    itemsList.add("3");
    itemsList.add("4");
    itemsList.add("5");
    itemsList.add("6");
    itemsList.add("7");

    ]]>
    </zscript>
    <listbox id="listbox" model="@{fooList}" height="200px" selectedItem="@{selectedFoo}">
    <listhead sizable="true">
    <listheader label="bar"/>
    <listheader label="item"/>
    </listhead>
    <listitem self="@{each=str}" value="@{str}">
    <listcell label="@{str.bar}"/>
    <listcell label="@{str.item}"/>
    </listitem>
    </listbox>
    <textbox id="textboxDesc" value="@{selectedFoo.bar,save-when='saveButton.onClick'}"/>
    <listbox model="@{itemsList}" selectedItem="@{selectedFoo.item,save-when='saveButton.onClick'}" mold="select">
    <listitem self="@{each=is}" value="@{is}" label="@{is}"></listitem>
    </listbox>
    <button id="saveButton" label="save"></button>
    </window>

     
  • Henri Chen

    Henri Chen - 2008-10-02
    • status: open --> closed-fixed
     

Log in to post a comment.

MongoDB Logo MongoDB