Pergunta

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.

Foi útil?

Solução

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

Outras dicas

I encountered the same problem: p:dataTable inside form is duplicated, each time an update(:form) is made.

One possibility to solve the problem is to put a p:outputPanel as major element inside the form which contains all other elements. When simply doing an update(:form:outputpanel) the table is update BUT not duplicated anymore.

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top