为什么newValue不包含提交的值。我总是得到旧的价值

时间:2014-08-28 10:52:44

标签: jsf primefaces

我正在尝试使用单元格编辑来实现primefaces数据表。 但是当我点击数据表来更改类型的值时,它不会改变 newValue不包含提交的值。我总是得到旧的价值!!

           <h:form id="cld">
              <h:form >
            <p:calendar value="#{bean.date1}" showOn="button" pattern="yyyy-MM-dd" 

                />    
            <p:commandButton value="OK" type="Submit"  actionListener="#{bean.click}"  

            update=":content:cld:data1"  />
           </h:form>
           <br/><br/>      
           </center>    
          <p:growl id="msgs" showDetail="true"/> 
        <p:dataTable id="table" var="data" value="#{bean.liste}"
                 editable="true" 
                 editMode="cell" 
                 widgetVar="cellInter"
                 styleClass="hovered striped table tblDataTable" >          
        <p:ajax event="cellEdit" listener="#{bean.onCellEdit}"   

          update=":content:cld:msgs"/> 
          <p:growl id="msgs" showDetail="true"/>           
        <p:column  sortBy="#{data.type}" filterBy="#{data.type}" 
        filterMatchMode="contains"  >  
            <f:facet name="header">
                <span class="nomColonneTab"  >Type  </span>
            </f:facet>
            <p:cellEditor>                
                <f:facet name="output">               
                    <p:outputLabel value="#{data.type}"/> 
                </f:facet>
                <f:facet name="input">
                    <h:inputText value="#{data.type}" />
                </f:facet>
            </p:cellEditor> 
        </p:column>**

-------&GT; ManagedBean:这是我的函数

public void onCellEdit(CellEditEvent event) {
    String oldValue = (String) event.getOldValue();
    String newValue = (String) event.getNewValue();

   System.out.println("-------------------------------------------- " + oldValue);
   FacesMessage msg = new FacesMessage(FacesMessage.SEVERITY_INFO, "Cell Changed", "Old: " + oldValue + ", New:" + newValue);
    FacesContext.getCurrentInstance().addMessage(null, msg);
    System.out.println("oldValue : " + oldValue + "\n newValue : " + newValue);

}

已修改

有完整列表的功能:

public void click() {
        liste = new ArrayList<>();
        for (Programme p : pfl.findByDate(date1)) {

            InterProgClass inter = new InterProgClass();
            inter.setProgramme(p);
            int r = (int) (date1.getTime() - p.getOperationSuivante().getTime()) / (1000 * 60 * 60 * 24);
            inter.setRetard(r);
            liste.add(inter);
        }

        for (InterventionInterne ii : pfl.findInterv(date1)) {
            InterProgClass inter = new InterProgClass();
            inter.setProgramme(ii.getProgramme());
            for (InterProgClass i : liste) {
                if (i.getProgramme().getIdIntervention() == inter.getProgramme().getIdIntervention()) {
                    i.setInterventioninterne(ii);
                    i.setType("Interne");

                }
            }
        }

        for (InterventionExterne iex : pfl.findIntervEx(date1)) {

            InterProgClass inter = new InterProgClass();
            inter.setProgramme(iex.getProgramme());

            for (InterProgClass i : liste) {
                if (i.getProgramme().getIdIntervention() == inter.getProgramme().getIdIntervention()) {

                    i.setInterventionexterne(iex);
                    i.setType("Externe");

                }
            }

        }

    }

0 个答案:

没有答案