I’m trying to update a part of my page using the following command:
<p:commandButton id="deleteDirectPaymentLine-#{counter.index}"
icon="fa fa-close Fs16 white"
action="#{step.deleteDirectPaymentLine(directPaymentLine)}"
process="@all"
rendered="#{directPayment.getDirectPaymentLineSet().size() gt 1}"
update="listDirectPaymentLines, container, totalAmount"
immediate="true"
ajax="false" />
When I click this button I need to update the panel which contains this button.
panelGroup:
<h:panelGroup id="listDirectPaymentLines">
<c:forEach var="directPaymentLine" items="#{step.directPaymentLineList}" varStatus="counter">
<r:propertyRow>
<r:property id="costType-#{counter.index}" width="HALF" label="Cost Type" value="#{directPaymentLine.claimCostType}"
objectList="#{entityListCache.getAllClaimCostTypes(entityInstance.costType, claim)}"
onChangeActionObject="#{step}" onChangeActionMethod="changeDirectPaymentLine"
reRenderPropertiesOnChange="totalAmount, claimDeductible-#{counter.index}, deductibleInRespectOfClaim-#{counter.index}"
hideNoSelectionLabel="false" required="true" />
<c:if test="#{!step.hasCoinsurance}">
<r:property id="amount-#{counter.index}" width="QUARTER" label="Amount" value="#{directPaymentLine.amount}"
onChangeActionObject="#{step}" onChangeActionMethod="changeDirectPaymentLine"
reRenderPropertiesOnChange="totalAmount" required="true" />
</c:if>
<r:property id="deleteButton-#{counter.index}" type="CUSTOM">
<p:commandButton id="deleteDirectPaymentLine-#{counter.index}"
icon="fa fa-close Fs16 white"
action="#{step.deleteDirectPaymentLine(directPaymentLine)}"
process="@all"
rendered="#{directPayment.getDirectPaymentLineSet().size() gt 1}"
update="listDirectPaymentLines, container, totalAmount"
immediate="true"
ajax="false" />
</r:property>
<c:if test="#{step.hasCoinsurance}">
<r:propertyRow>
<r:property width="HALF" id="hundredPercentAmount-#{counter.index}" label="100% Amount" value="#{directPaymentLine.oneHundredPercentAmount}"
onChangeActionObject="#{step}" onChangeActionMethod="changeHundredPercentAmount"
reRenderPropertiesOnChange="totalAmount, totalHundredPercentAmount, amount-#{counter.index}" />
<r:property width="HALF" id="amount-#{counter.index}" label="Our Share Amount" value="#{directPaymentLine.amount}"
onChangeActionObject="#{step}" onChangeActionMethod="changeDirectPaymentLine"
reRenderPropertiesOnChange="totalAmount, totalHundredPercentAmount, hundredPercentAmount-#{counter.index}" />
</r:propertyRow>
</c:if>
</r:propertyRow>
<r:propertyRow>
<r:property width="HALF" label="Claim deductible" id="claimDeductible-#{counter.index}" value="#{directPaymentLine.claimDeductible}"
objectList="#{step.getClaimDeductibles(directPaymentLine)}"
rendered ="#{step.isRenderClaimDeductible(directPaymentLine)}"
displayProperty="amountDisplayDescription"
onChangeActionObject="#{step}" onChangeActionMethod="changeDirectPaymentLine"
hideNoSelectionLabel="false" required="true" />
<r:property label="Deductible In Respect of" id="deductibleInRespectOfClaim-#{counter.index}" value="#{directPaymentLine.deductibleInRespectOf}"
width="HALF"
objectList="#{entityListCache.getAllDeductibleInRespectOfs(directPaymentLine.deductibleInRespectOf)}"
rendered="#{step.isRenderClaimDeductible(directPaymentLine)}"
onChangeActionObject="#{step}" onChangeActionMethod="changeDirectPaymentLine"
hideNoSelectionLabel="false" required="true" />
</r:propertyRow>
</c:forEach>
The Delete method which is called from the command button is below:
public void deleteDirectPaymentLine(DirectPaymentLine dpl) {
linkedHashSet.remove(dpl);
directPaymentLineList.remove(dpl);
//directPayment.setDirectPaymentLineSet(linkedHashSet);
directPaymentService.deleteDirectPaymentLine(directPayment, dpl);
if (hasCoinsurance) {
directPaymentService.recalculateTotalHundredPercentAmount(directPayment);
}
}
May someone knows why the panel is not updated? When I debug the delete method, I can see that the right object is deleted but it's not updated in the view. If I delete the last element of the list, works properly, but if I delete something else then a different line is deleted. Example:
- PObject 1
- PObject 2
- PObject 3
- PObject 4
When the object 4 is deleted the new list contains only the first 3 elements. But in case of deletion of the Object 3 or 2 then the last line is deleted again, but only in the view.
Need somejow to enforce the panelGroup to be updated with the new values.