Search code examples
datatablejsf-2primefacesduplication

Primefaces dataTable is duplicated on page


Have review(for adding review or comments) component in my application.
When add review, that p:dataTable is updated with ajax.

before adding review:
enter image description here
after adding first review
enter image description here
refresh page(F5):
enter image description here
after adding second review:
enter image description here

jsf:

<h:form onsubmit="return commValidator();">
 <h:inputText value="#{comment.commentator}"/>
 <h:inputTextarea value="#{comment.body}";"/>
 <p:commandButton  value="send" action="#{showProducts.addComment}" update="comms"/>
 <p:dataTable id="comms" value="#{showProducts.comments}" var="com">   
  <p:column>#{com.commentator}(
   <h:outputText value="#{com.postDate}">
   </h:outputText>):
  </p:column>
  <p:column>#{com.body}</p:column>
 </p:dataTable> 
</h:form>

The problem is p:dataTable component is displayed twice on page.
After new review been added, that newly created p:dataTable displayed.
How to make p:dataTable displayed already after go to page and once time?

Thanks.


Solution

  • p:dataList component resolves this problem

    It displays ones and new elem. is added to already existing list instead of creating new one list as with p:dataTable!

    forum