Empty dataTable can NOT be reRendered
j-pro Apr 21, 2008 3:58 PMGood afternoon, dear RF developers.
It seemed strange to me, but I've faced such a problem: I have this rich:dataTable on my page:
<c:if test="#{amBean.employee.relativeListSize > 0}"> <rich:dataTable id="relativesDataTable" onRowClick="this.style.backgroundColor='#F1F1F1'" onRowMouseOver="this.style.backgroundColor='#B5CEFD'" onRowMouseOut="this.style.backgroundColor='#{org.richfaces.SKIN.tableBackgroundColor}'" cellpadding="0" cellspacing="0" style="width:100%" value="#{amBean.employee.relativeList}" var="rudele"> <f:facet name="header"> <rich:columnGroup> <rich:column> <h:outputText value="#{muiBundle.dTableID}" /> </rich:column> <rich:column> <h:outputText value="#{muiBundle.dTableNumber}" /> </rich:column> <rich:column> <h:outputText value="#{muiBundle.dTableBirthDate}" /> </rich:column> <rich:column> <h:outputText value="#{muiBundle.dTableBirthPlace}" /> </rich:column> <rich:column> <rich:spacer/> </rich:column> </rich:columnGroup> </f:facet> <rich:column> <h:outputText value="#{rudele.relativeId}" /> </rich:column> <rich:column> <h:outputText value="#{rudele.name}" /> </rich:column> <rich:column> <h:outputText value="#{rudele.birthDate}" /> </rich:column> <rich:column> <h:outputText value="#{rudele.birthPlace}" /> </rich:column> <rich:column> <a4j:commandLink id = "delRelLink" value = "X" styleClass="txtlink" action = "#{amBean.action4RelativeRemoveFromList}" reRender = "relativesDataTable"> <a4j:actionparam value="#{rudele.id4DataTable}" name="id4DataTable_del" assignTo="#{amBean.parameterID}"/> </a4j:commandLink> </rich:column> </rich:dataTable> </c:if>
As you see, there is a link for deletion in the end of each row. The method action4RelativeRemoveFromList just removes an element from a list, then the table should be reRendered because of reRender = "relativesDataTable". And it is reRendered, but only if there is 1 and more rows. So if there is 3 elements and I delete one - the table reRenders with 2. I delete one more - it reRenders with 1. I delete the last one, logs write that element was deleted and the list is empty, but the table is NOT reRendered.
Yes, there is JSTL c:if element - and it works perfect if I put it between <a4j:outputPanel> and will reRender it whole. But what's wrong with rich:dataTable?
I've tried some experiments like making the list equal null or "new ArrayList()" in method action4RelativeRemoveFromList - just after that the table stops reRendering.
Maybe it's my fault somewhere, but still - it's better to ask in case of a bug.
Thanks for the answer.