Jsf <;p:commandLink>;更新<;p:datatable>;仅在第二次单击后

Jsf <;p:commandLink>;更新<;p:datatable>;仅在第二次单击后,jsf,primefaces,datatable,action,jsf-2.2,Jsf,Primefaces,Datatable,Action,Jsf 2.2,基本上,我试图从启动一个操作来更新和 会立即更新,但只有在第二次单击后才会更新 以下是XHTML代码: <h:body> <h:form id="form1" > <p:layout id="layout"> <p:layoutUnit id="north" position="north"> <p:growl id="msg" showDetail="true" /> <h:column&

基本上,我试图从
启动一个操作来更新

会立即更新,但只有在第二次单击后才会更新

以下是XHTML代码:

<h:body>
<h:form id="form1" > 
 <p:layout id="layout"> 
   <p:layoutUnit id="north" position="north">
      <p:growl id="msg" showDetail="true" />
        <h:column>
          <p:commandButton id="searchdate"
                            value="Rechercher"
                            actionListener="#{dyna.search}"
                            update=":form1:tabexam,:form1:msg"/>
        </h:column>
   </p:layoutUnit>
 <p:layoutUnit position="center"
               resizable="true"
               collapsible="true"
               effect="drop"
               size="300"
               styleClass="heighter">  

      <p:dataTable id="tabexam"
                   paginatorPosition="bottom"
                   var="exam"
                   value="#{dyna.listexam}"
                   widgetVar="examTable"
                   emptyMessage="aucun résultat."
                   filteredValue="#{dyna.filteredexams}"
                   paginator="true"
                   rows="20"
                   rowsPerPageTemplate="10,20,40,80"
                   binding="#{dyna.table}">

          <f:facet name="header" >  
               <h:outputText value="Rechercher: "/>  
              <p:inputText id="globalFilter"
                           onkeyup="examTable.filter();" 
                           style="width:200px" /> 
          </f:facet>  
      </p:dataTable>
</p:layoutUnit>      
<p:layoutUnit position="west" resizable="false" header="Liste Perso.">
 <ui:repeat  var="list" value="#{userBean.userLists}">
   <center>
     <p:commandLink id="listerlink"
                    title="Afficher la liste"
                    action ="#{dyna.refreshChildren(list.id.tbCode)}"
                    update=":form1:tabexam,:form1:msg">      
       <p:graphicImage id="imglist"  value="/images/Liste_Cold.png"/><br></br>
       <p:outputLabel value="#{list.id.tbCode}" /><br></br>
     </p:commandLink>
   </center>
 </ui:repeat>
</p:layoutUnit>
</h:form>
</h:body>





下面是我的ManagedBean中的一些代码

@ManagedBean(name = "dyna", eager = true)
@SessionScoped
public class DynamicDatatable implements java.io.Serializable {
@PostConstruct
public void init() {

    listexam = DAO_Examen.getAllExamens();
    selectedExamen = new Cotation();
    etatExamOptions = createFilterOptions();
    payExamOptions = createFilterOptions2();
    salleOptions = DAO_Salle.getAllSalle(UserBean.user.getUserId());
    refreshChildren("default");

}
public void refreshChildren(String listid) {
    try {
        //config
        FacesContext fc = FacesContext.getCurrentInstance();
        Application application = fc.getApplication();
        ExpressionFactory ef = application.getExpressionFactory();
        ELContext elc = fc.getELContext();

        //Table
        table = (DataTable) application.createComponent(DataTable.COMPONENT_TYPE);

        //columns spec.
        ArrayList<ColumnModel> columnmodel = DAO_UserLists.createUserColumnSpec(UserBean.user.getUserId(), "SITE1", listid);

        if (columnmodel != null) {

            for (int i = 0; i < columnmodel.size(); i++) {

                if ((columnmodel.get(i) != null) && (columnmodel.get(i).getDbname() != null)) {

                    Column column = (Column) application.createComponent(Column.COMPONENT_TYPE);
                    column.setHeaderText(columnmodel.get(i).getUserListname());
                    column.setWidth("10");
                    column.setId("Col_" + columnmodel.get(i).getHeadername());
                    column.setStyleClass("dispo");
                    column.setSortBy(columnmodel.get(i).getDbname());
                    column.setRendered(columnmodel.get(i).isVisible());
                    table.getChildren().add(column);
}
   }

   FacesMessage msg = new FacesMessage("Terminé avec succes", "la liste " + listid + " est bien chargée");
  FacesContext.getCurrentInstance().addMessage(null, msg);

    } catch (Exception e) {
        e.printStackTrace();
    }
   }
  }
}
@ManagedBean(name=“dyna”,eager=true)
@会议范围
公共类DynamicDatatable实现java.io.Serializable{
@施工后
公共void init(){
listexam=DAO_Examen.getAllexamen();
selectedExamen=新的Cotation();
etatExamOptions=createFilterOptions();
payExamOptions=createFilterOptions2();
salleOptions=DAO_Salle.getAllSalle(UserBean.user.getUserId());
刷新子项(“默认”);
}
公共子项(字符串listid){
试一试{
//配置
FacesContext fc=FacesContext.getCurrentInstance();
Application Application=fc.getApplication();
ExpressionFactory ef=application.getExpressionFactory();
ELContext elc=fc.getELContext();
//桌子
table=(DataTable)application.createComponent(DataTable.COMPONENT\u类型);
//柱规格。
ArrayList columnmodel=DAO_UserLists.createUserColumnSpec(UserBean.user.getUserId(),“SITE1”,listid);
if(columnmodel!=null){
对于(int i=0;i
API的版本: JSF2.2
primefaces 4.0

refreshChildren()方法在第一次单击时是否成功执行?是的,方法refreshChildren()在第一次单击时执行,但更新要到第二次单击才会发生。它很大,哪一部分对您最重要?@Papa_Jay-:您可以添加一个属性
process=“tabexam”
中的
。将UI组件绑定到比请求范围更广的bean确实是在自找麻烦(组件即请求范围)。为什么不直接使用