为了更好的控制数据绑定管理器,你可以设置的attribute-name的模式为both(加载/保存),load(仅加载), save(仅保存),或 none(都不可)。
<component-name attribute-name="@{bean-name.attribute-name,access='type-name'}"/>
type-name描述特定的访问模式。不允许多重定义,后面的定义会重写前面的定义。
在下面的例子中,如果Textbox,"firstName",和 "lastName"的值被修改,Listcell,"fullname"的值仍不会改变,因为数据绑定管理器被设置为禁止修改。
<?init class="org.zkoss.zkplus.databind.AnnotateDataBinderInit"?>
<window width="500px">
<zscript>
Person person = new Person();
person.setFirstName("Bill");
person.setLastName("Gates");
</zscript>
<listbox>
<listhead>
<listheader label="First Name" width="100px"/>
<listheader label="Last Name" width="100px"/>
<listheader label="Full Name" width="100px"/>
</listhead>
<listitem>
<listcell>
<textbox id="firstName" value="@{person.firstName}"/>
</listcell>
<listcell>
<textbox id="lastName" value="@{person.lastName}"/>
</listcell>
<listcell id="fullName" label="@{person.fullName, access='none'}"/>
<listitem>
</listbox>
</window>