jsf ajax按钮从列表中删除元素,但ajax不会重新呈现datatable

jsf ajax按钮从列表中删除元素,但ajax不会重新呈现datatable,ajax,jsf,datatable,Ajax,Jsf,Datatable,我有个奇怪的问题。我得到了一个数据表,在其中我显示了对象列表。代码如下: <h:dataTable value="#{XXXX.questions}" var="q" binding="#{varQ}" id="YYY"> <h:column> <f:facet name="header"> header </f:facet

我有个奇怪的问题。我得到了一个数据表,在其中我显示了对象列表。代码如下:

<h:dataTable value="#{XXXX.questions}" var="q" binding="#{varQ}" id="YYY">
  <h:column>
    <f:facet name="header">
      header
    </f:facet>
     #{q.question}
  </h:column>
    <h:commandButton value="-" action="#{XXX.removeQuestion(varSurvey.index, varSec.index, varQ.rowIndex)}">
    <f:ajax execute="@this" render="YYY"/>
   </h:commandButton>
  </h:column>
</h:dataTable>
正如你所看到的,这几乎是一个基本的例子

以下是同一页中我的另一个表的代码:

<h:dataTable value="#{XXX.answers}" id="ZZZ" var="ans">
  <h:column>
     <h:inputText value="#{ans.choice}" styleClass="form-control">
        <f:ajax event="change" execute="@this"/>
     </h:inputText>
  </h:column>
<f:facet name="footer">
  <h:commandButton value="+" action="#{XXX.addMoreQuestions()}">
    <f:ajax execute="@this" render="ZZZ"/>
  </h:commandButton>
</f:facet>
</h:dataTable>

这是有效的——当我单击按钮时,它会向列表中添加一个问题,并使用另一个选项重新提交datatable。

您是否已从列表中删除该项XXXX。问题?正如我之前所写的——是的,删除方法很好——当我单击按钮时,然后手动刷新页面datatable会缩短一条记录。
<h:dataTable value="#{XXX.answers}" id="ZZZ" var="ans">
  <h:column>
     <h:inputText value="#{ans.choice}" styleClass="form-control">
        <f:ajax event="change" execute="@this"/>
     </h:inputText>
  </h:column>
<f:facet name="footer">
  <h:commandButton value="+" action="#{XXX.addMoreQuestions()}">
    <f:ajax execute="@this" render="ZZZ"/>
  </h:commandButton>
</f:facet>
</h:dataTable>
public void addMoreQuestions(){
    answers.add(new Choice("question"));
}