I am having a problem on my application, what I am trying to do is when ever someone changes the field shopStatus on the form to Pass, i want it to update my field shopApprovalDate to be mandatory. I am using the following event listener for this
@EventListener(targets="shopStatus", events="onchange")
public void onLicenseStatusChange(IRequestCycle cycle) {
cycle.getResponseBuilder().updateComponent("shopStatus");
cycle.getResponseBuilder().updateComponent("shopApprovalDateRequired");
cycle.getResponseBuilder().updateComponent("shopApprovalDate");
}
this is the html that I am using for this
<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>
The thing is that, if I change the shopStatus to Pass nothing happens, but if i save the page and reload the page, then the shopApprovalDate is set to mandatory so the html code is working, it is like the @EventListener is not updating shopApprovalDate when shopStatus is changed! I have debugged through the code and it is hitting the listener but nothing is happeneing
Does anyone have any ideas on this?
This is because you need to call an update on something that calls the @IF @Else and not the actual component itself
If you add a outside the @If @Else and call that in the Event Listener this should work then like so
The
<div>The event listener