-
FEATURED COMPONENTS
First time here? Check out the FAQ!
Hi all,
操作圖
操作功能:
所有欄位預設readonly is true.
當使用者選某列(row)後, 按下修改按鈕,
我想取得該列(row)的第一欄位,如圖,FirstName的id 並設readonly is false,
當第一個欄位Enter(onOK) 再取得第二欄位LastName的id 並設為 readonly is false, 同時第一欄位設為readonly is true.
目前遇到 當按下修改Button後, 會得到"Fellow component not found: id_frist" 訊息.
不知如何解決?
Thanx.
listbox_binding.zul
<?page title="Data binding 5" contentType="text/html;charset=UTF-8"?> <?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit" ?> <window id="win" title="Data binding 5" border="normal" use="com.sanq.test.Listbox_binding_win"> <zscript><![CDATA[ //prepare the sample List import com.sanq.test.Person; int count = 3; List persons = new ArrayList(); for(int j= 1; j <= count; ++j) { Person personx = new Person(); personx.setFirstName("Tony"+j); personx.setLastName(""+j); persons.add(personx); } ]]></zscript> <listbox rows="4" model="@{persons}"> <listhead> <listheader label="First Name" width="100px" /> <listheader label="Last Name" width="100px" /> <listheader label="Full Name" width="100px" /> </listhead> <!-- define variable person here--> <listitem self="@{each='person'}"> <listcell> <textbox id="id_first" value="@{person.firstName}" readonly="true"/> </listcell> <listcell> <textbox id="id_last" value="@{person.lastName}" readonly="true"/> </listcell> <listcell id="id_full" label="@{person.fullName}"/> </listitem> </listbox> <separator bar="false"/> <hbox> <button label="修改F3" onClick="win.onModify()"/> </hbox> </window>
Controller, Listbox_binding_win.java
package com.sanq.test; import org.zkoss.zul.Textbox; import org.zkoss.zul.Window; public class Listbox_binding_win extends Window { public void onModify() { Textbox tb = (Textbox) getFellow("id_first"); //tb.setReadonly(false); //tb.setFocus(true); } }
<listitem self="@{each='person'}"> <listcell> <textbox id="id_first" value="@{person.firstName}" readonly="true"/> </listcell> <listcell> <textbox id="id_last" value="@{person.lastName}" readonly="true"/> </listcell> <listcell id="id_full" label="@{person.fullName}"/> </listitem>
You can traverse the component tree to get the component you need.
getSelectedItem().getFirstChild().getFirstChild(); //get id_first textbox
getSelectedItem().getFirstChild().getNextSibling().getFirstChild(); //get id_last textbox
Finally, I got it fixed ZK task it work fine, Thank you for your help, Henri.
Asked: 2011-02-15 07:45:12 +0800
Seen: 1,210 times
Last updated: Mar 05 '11