Java 使用PrimeFaces执行ajax后无法刷新到DataTable

Java 使用PrimeFaces执行ajax后无法刷新到DataTable,java,jsf,primefaces,Java,Jsf,Primefaces,我想在添加操作后刷新DataTable,但它不起作用。 下面是我的代码 此代码是使用数据库中的netbeans jsf实体类生成的。 我确信下面的所有代码都能顺利执行,没有任何错误 javascript代码 function update(){ updateComment(); } view.xhtml <h:form id="commentArea"> <!--for Comment Area-->

我想在添加操作后刷新DataTable,但它不起作用。 下面是我的代码

此代码是使用数据库中的netbeans jsf实体类生成的。 我确信下面的所有代码都能顺利执行,没有任何错误

javascript代码

 function update(){
       updateComment();
    }
view.xhtml

<h:form id="commentArea">
              <!--for Comment Area-->
             rendered="#{issueCommentController.items.rowCount == 0}" style="padding-bottom: 10px;"/><br/>
              <h:panelGroup>
                <h:dataTable id="commentTable" value="#{issueCommentController.getCommentModel(issueController.selected.id)}" var="comment" class="table table-striped table-bordered table-condensed table-hover" rules="all">
                  <h:column>
                    <f:facet name="header">
                      <h:outputText value="Comment"/>
                    </f:facet>
                    <h:outputText value="#{comment.comment}"/>
                  </h:column>
                  <h:column>
                    <f:facet name="header">
                      <h:outputText value="Comment Date"/>
                    </f:facet>
                    <h:outputText value="#{comment.commentedDate}">
                      <f:convertDateTime pattern="MM/dd/yyyy" />
                    </h:outputText>
                  </h:column>
                </h:dataTable>
              </h:panelGroup>
              <h:inputTextarea id="reply-thread-txt" value="#{issueCommentController.selected.comment}"></h:inputTextarea>
              <div style="clear:both"></div>
              <div class="padding-top-10" style="width:284px !Important; margin-top: 10px;">
<p:remoteCommand name="updateComment" action="#{issueCommentController.retrieveComment(issueController.selected.id)}" update="commentArea"/>
                <p:commandButton styleClass="btn btn-primary" oncomplete="update();" value="Reply" action="#{issueCommentController.create}">
                  <f:param name="issue.id" value="#{issueController.selected.id}"/>
                  <f:param name="commented.by" value="#{sessionScope.LOGIN_USER}"/>
                </p:commandButton>
              </div>
            </h:form>
IssueCommentController.java

public DataModel getCommentModel(int id){
    if(commentModel == null){
      commentModel = getCommentPagination(id).createPageDataModel();
    }
    return commentModel;
  }

//comment pagination.
public PaginationHelper getCommentPagination(final int id) {
    if (commentPagination == null) {
      commentPagination = new PaginationHelper(10) {
        @Override
        public int getItemsCount() {
          return getFacade().count();
        }

        @Override
        public DataModel createPageDataModel() {
          return new ListDataModel(getFacade().getComment(id));
        }
      };
    }
    return commentPagination;
  }
//execuate query
 public List<IssueComment> getComment(int id){
    TypedQuery<IssueComment> tq = getEntityManager().createQuery("SELECT c FROM IssueComment AS c WHERE c.issueId=:id",IssueComment.class);
    Issue issue = new Issue(id);
    tq.setParameter("id", issue);
    return tq.getResultList();
  }
//execute after the add operation using ajax.
 public void retrieveComment(int id) {
    items = getCommentPagination(id).createPageDataModel();
  }
添加操作后,将执行此操作

<p:remoteCommand name="updateComment" action="#{issueCommentController.retrieveComment(issueController.selected.id)}" update="commentArea"/>
但它不会刷新数据表

任何帮助都将不胜感激。
thnks.

我找到了解决问题的方法,但我会把我的答案贴出来,以防对其他人有所帮助。 我从中替换了remoteCommand代码

<p:remoteCommand name="updateComment" action="#{issueCommentController.retrieveComment(issueController.selected.id)}" update="commentArea"/>
对这个

 <p:remoteCommand name="updateComment" action="#{issueCommentController.getCommentModel(issueController.selected.id)}" update="commentArea"/>

rendered={issueCommentController.items.rowCount==0}属于视图中的哪个元素?为什么要在update和updateComment之间往返?你知道你可以直接从命令按钮引用updateComment,而不是不必要的js?哦,对不起,我忘了编辑那个。应该是它的呈现={issueCommentController.getCommentModelissueController.selected.id==0}。关于更新和updateComment,我使用另一个js调用updateComment,因为我计划在调用它之前添加一个模态。