<ui:repeat>
is showing a strange behaviour. I am showing some textfields and a delete link in <ui:repeat>
. When delete link is clicked, the correct row is being deleted from backend, but the view still shows the deleted row, and the next row is missing instead.
Code:
<h:form>
<ui:repeat var="tarrifDetail" value="#{tarrifBean.tarrifDetails}">
<br />
<p:inputTextarea id="tarrifDetailName" value="#{tarrifDetail.tarrifName}" rows="2" cols="38">
<p:watermark value="Tarrif Name" for="tarrifDetailName" />
</p:inputTextarea>
<p:spacer width="6" />
<p:inputTextarea id="tarrifDetailValue" value="#{tarrifDetail.tarrifValue}" rows="2" cols="38">
<p:watermark value="Tarrif Value" for="tarrifDetailValue" />
</p:inputTextarea>
<p:spacer width="6" />
<p:commandLink value="Delete" action="#{tarrifBean.deleteTarrifDetail(tarrifDetail)}" update="@form" />
<br />
</ui:repeat>
</h:form>
tarrifBean:
public void deleteTarrifDetail(TarrifDetailManagedBean detail) throws Throwable
{
try
{
TarrifDetailManagerImpl.getInstance().deleteByPrimaryKey(detail.getTarrifDetailId());
tarrifDetails.remove(detail);
// problem is not solved even with this temp list scene part
List<TarrifDetailBean> temp = new ArrayList<TarrifDetailBean>();
temp.addAll(tarrifDetails);
tarrifDetails = temp;
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "Successfully deleted tarrif detail", null));
}
When I press Delete link of first row in ui:repeat, correct element is deleted from database, and from the list(I have debugged the code), BUT in the view, first row is still being shown, and second row is deleted instead.