2013-11-21 27 views
2

我正尝试使用允许用户编辑表格中的单元格数据的主要面的特征。我按照此链接实现它: Primefaces showcasePrimefaces在单元格编辑数据表中event.getNewValue()将旧值发送给bean

当我说在表中编辑单元格时,输入的新值不会发送到bean。它仍然只显示旧值。

我的代码JSF:

<h:form id="testform">    
    <p:growl id="messages" showDetail="true" /> 
<p:outputPanel id="testContainer" deferred="true">   




    <p:remoteCommand name="oncompleteCellEdit" update="cars messages" /> 

    <p:dataTable id="cars" var="car" value="#{articlesbean.LMatpilotaccess1}" editable="true" editMode="cell" widgetVar="carsTable" update=":cars"> 

     <f:facet name="header"> 
      Matériel du pilotage et accessoires 
     </f:facet> 

    <p:ajax event="cellEdit" listener="#{articlesbean.onCellEdit}" oncomplete="oncompleteCellEdit()" update=":testform:messages" /> 

     <p:column headerText="Serie" style="width:25%">     

       <p:cellEditor > 
        <f:facet name="output"><h:outputText value="#{car.serie}" /></f:facet> 
        <f:facet name="input"><p:inputText id="modelInput16" value="#{car.serie}" style="width:96%"/></f:facet> 
       </p:cellEditor> 
     </p:column> 


    <p:column headerText="Cap" style="width:25%">     

       <p:cellEditor > 
        <f:facet name="output"><h:outputText value="#{car.cap}" /></f:facet> 
        <f:facet name="input"><p:inputText id="modelInput15" value="#{car.cap}" style="width:96%"/></f:facet> 
       </p:cellEditor> 
     </p:column> 

    </p:dataTable> 

</p:outputPanel> 

    </h:form> 

我的代码豆

@ManagedBean(name="articlesbean") 

    @ViewScoped 
    public class ArticlesBean implements Serializable{ 

     @Inject 
     private ArticlesDAO articleDAO; 
     private Matpilotaccess1 matpilotaccess1; 

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

      System.out.println("/////"+(event.getNewValue()); 
      System.out.println("/////"+(event.getOldValue()); 

     FacesContext context = FacesContext.getCurrentInstance(); 
      Matpilotaccess1 mpltiacc = context.getApplication().evaluateExpressionGet(context, "#{mpltiacc}", Matpilotaccess1.class); 
      articleDAO.Updatetable(mpltiacc); 
       } 
/////////Getters and Setters 
    } 

,并作为

System.out.println("/////"+(event.getNewValue()); 
System.out.println("/////"+(event.getOldValue()); 

结果我在这两个情况下拿到了旧值!

任何人都可以让我知道我怎样才能得到新值???我使用JBoss 7和primefaces4感谢

+0

是LMatpilotaccess1的一个列表?我知道这是2年前,但我偶然发现了这个问题。 – toscanelli

回答

-3

您需要@SessionScoped进行注解你的bean。

+0

我试过了,但同样的问题仍然存在! –

相关问题