使用Tapestry更新选择字段上的渲染时出现问题。
我想禁用2个字段(1个文本字段和1个选择字段),具体取决于我在另一个字段(也是选择字段)中选择的内容。我想立即渲染禁用的字段,所以我使用Tapestry Zone系统来这样做。
但是当我从" fruitOrVegetableSelect"中选择一个项目时,我继续为选择字段获得以下异常。列表:
Parameter 'model' of component fruit/Edit:fruitNames is bound to null. This parameter is not allowed to be null.
以下是我在tml页面中的代码:
<t:zone t:id="fruitsForEveryOneZone" update="show">
<tr>
<td> <t:select
t:id="fruitName" t:model="fruitNames"
value="fruit?.fruitName"
disabled="getDisabledFruitField()" />
</td>
<td><t:textfield t:id="numberOfFruits"
value="fruit?.quantity"
disabled="getDisabledFruitField()" />
</td>
</tr>
</t:zone>
以下是控制器中的代码:
@OnEvent(component = "fruitOrVegetableSelect", value = EventConstants.VALUE_CHANGED)
public Object updateFruitOrVegetable(Plant plant)
{
if (plant.getName().equals("Fruit"){
this.disabledFruitField=false;
else {
this.disabledFruitField=true;
}
return new MultiZoneUpdate("fruitsForEveryOneZone", fruitsForEveryOneZone.getBody());
}
如果我限制区域所以它只需要文本字段输入就可以正常工作(除了我的选择永远不会被禁用)。出于某种原因,&#34;模型&#34;来自我的选择字段在此过程中丢失。知道为什么会这样,以及如何避免这个问题?
非常感谢,
此致
答案 0 :(得分:-1)
此代码未显示在Java类中如何声明“ fruitNames”。我想,“fruitNames”是一个变量,它只是失去了。您应该用@Persist
注释“ fruitNames”,这应该可以解决问题,或者将“ fruitNames”声明为方法(getFruitNames()
)。