2

我的应用程序有问题,我想做的是当有人shopStatus将表单上的字段更改为时Pass,我希望它更新我的字段shopApprovalDate为必填项。我为此使用以下事件侦听器

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

}

这是我为此使用的 html

<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>

问题是,如果我将 更改shopStatusPass没有任何反应,但如果我保存页面并重新加载页面,则shopApprovalDate设置为强制,因此 html 代码正在工作,就像更改时@EventListener没有更新一样!我已经通过代码进行了调试,它击中了监听器,但没有发生任何事情shopApprovalDateshopStatus

有人对此有任何想法吗?

4

1 回答 1

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");
}
于 2012-08-27T11:39:40.990 回答