📄 b30-1813055.zul
字号:
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?>
<zk xmlns:h="http://www.w3.org/1999/xhtml" xmlns:zk="http://www.zkoss.org/2005/zk">
<html><![CDATA[
Two listbox share the same selected variable. It used to cause NullPointerException.<br/>
1. You should see 10 same Listitem on two listbox.<br/>
2. Change listbox 1's current selected item, listbox 2 should change its selection to the same item accordingly.<br/>
3. Change listbox 2's current selected item, listbox 1 should change its selection to the same item accordingly.
]]></html>
<zscript><![CDATA[
public class Person {
private String _first;
private String _last;
public Person(String f, String l) {
setFirstName(f);
setLastName(l);
}
public String getFirstName() {
return _first;
}
public void setFirstName(String f) {
_first = f;
}
public String getLastName() {
return _last;
}
public void setLastName(String l) {
_last = l;
}
}
List persons = new ArrayList(10);
for(int j=0; j < 10; ++j) {
persons.add(new Person("First"+j, "Last"+j));
}
Person selected = persons.get(0);
]]></zscript>
<groupbox>
<caption label="listbox1"/>
<listbox model="@{persons}" selectedItem="@{selected}">
<listitem each="@{person}">
<listcell label="@{person.firstName}"/>
<listcell label="@{person.lastName}"/>
</listitem>
</listbox>
</groupbox>
<groupbox>
<caption label="listbox2"/>
<listbox model="@{persons}" selectedItem="@{selected}">
<listitem each="@{person2}">
<listcell label="@{person2.firstName}"/>
<listcell label="@{person2.lastName}"/>
</listitem>
</listbox>
</groupbox>
</zk>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -