@EventListener& IRequestCycle.getResponseBuilder.updateComponent不更新组件

时间:2012-08-23 08:29:20

标签: java html tapestry event-listener

我的应用程序出现问题,我想要做的是当有人将表单上的字段shopStatus更改为Pass时,我希望它更新我的字段{{1强制性的。我正在使用以下事件监听器

shopApprovalDate

这是我正在使用的HTML

@EventListener(targets="shopStatus", events="onchange")
public void onLicenseStatusChange(IRequestCycle cycle) {
    cycle.getResponseBuilder().updateComponent("shopStatus");
    cycle.getResponseBuilder().updateComponent("shopApprovalDateRequired");
    cycle.getResponseBuilder().updateComponent("shopApprovalDate");

}

问题是,如果我将<td valign="center" align="left" class="rightTD" height="30" > <span jwcid="@If" condition="ognl:company.shopStatus == @valueobject.ShopStatus@Pass" renderTag="literal:false"> <input jwcid="shopApprovalDateRequired@CustomDatePicker" disabled="ognl:disabled || isShopApprovalDateDisabled()" value="ognl:company.shopApprovalDate" displayName="message:company.shopApprovalDate" validators="validators:maxDateToday,required" /> </span> <span jwcid="@Else" renderTag="literal:false"> <input jwcid="shopApprovalDate@CustomDatePicker" disabled="ognl:disabled || isShopApprovalDateDisabled()" value="ognl:company.shopApprovalDate" displayName="message:company.shopApprovalDate" validators="validators:maxDateToday" /> </span> </td> 更改为shopStatus没有任何反应,但如果我保存页面并重新加载页面,那么Pass将设置为必需,因此HTML代码正常工作,就像shopApprovalDate更改@EventListenershopApprovalDate没有更新shopStatus!我已经通过代码进行了调试,它正在触及听众,但没有发生任何事情

有没有人对此有任何想法?

1 个答案:

答案 0 :(得分:3)

这是因为您需要调用调用@IF @Else而不是实际组件本身的更新

如果你在@If @Else之外添加一个并在事件监听器中调用它,那么这应该是这样的

<div>

<div jwcid="licenceAuthRequiredDiv@Any">
<td valign="center" align="left" class="rightTD" height="30" >
     <span jwcid="@If" condition="ognl:company.shopStatus == @valueobject.ShopStatus@Pass" renderTag="literal:false">
        <input jwcid="shopApprovalDateRequired@CustomDatePicker" disabled="ognl:disabled || isShopApprovalDateDisabled()"
        value="ognl:company.shopApprovalDate" displayName="message:company.shopApprovalDate" validators="validators:maxDateToday,required" />
     </span>
     <span jwcid="@Else" renderTag="literal:false">
        <input jwcid="shopApprovalDate@CustomDatePicker" disabled="ognl:disabled || isShopApprovalDateDisabled()"
        value="ognl:company.shopApprovalDate" displayName="message:company.shopApprovalDate" validators="validators:maxDateToday" />
     </span>
    </td>
</div> 

事件监听器

@EventListener(targets="licensingStatus", events="onchange")
public void onLicenseStatusChange(IRequestCycle cycle){
    cycle.getResponseBuilder().updateComponent("licenceAuthRequiredDiv");
}