2013-12-11 27 views
0

我試圖實現一個dataTable,其中包含一個帶有textInput的列,以便我可以修改該bean中的字符串值。我的問題是,豆不正確地更新,所以這是我的代碼部分:p:inputText在p:dataTable中沒有設置bean的值

<p:scrollPanel style="height:625px" mode="native"> 

    <p:dataTable value="#{oaBean.documentos}" var="documento" 
     rowIndexVar="rowIndexVar" rowKeyVar="documentoKey" id="documentoList" 
     widgetVar="myTableWidget" paginator="true" rows="50" 
     emptyMessage="#{messages['norecords']}"> 

     <f:facet name="header"> 
      <h:outputText value="#{messages['documents']}" /> 
     </f:facet> 
     <p:column style="width:1px;margin:0;padding:0;" headerText="#"> 
      <h:outputText value="#{rowIndexVar+1}" 
       style="font-size:0.75em;margin:0;padding:0;" /> 
     </p:column> 
     //lots of another columns 
     <p:column headerText="#{messages['documento.orden']}" 
       style="width:25px; text-align: center" id="columnOrden" widgetVar="columnOrden"> 
       <p:inputText id="ordenDocumento" value="#{documento.orden}" 
       disabled="#{documento.eliminado}" style="font-size:0.9em" size="2" 
       validator="floatValidator"> 
       </p:inputText> 
     </p:column> 
    </p:dataTable> 
</p:scrollPanel> 

的事情是,控制返回到bean沒有更新的orden值的時候,我總是有老值。我也試過爲change事件添加一個ajax監聽器,它似乎工作正常,但如果我改變例如5行,至少其中一個維護舊值,所以我的問題是:是否有任何已知的問題與dataTables和textInputs?我的代碼有問題嗎?

任何幫助將非常感激,先謝謝你們。
UPDATE
對不起,我忘記了包含一些信息。首先,我正在與Mojarra 2.1.5,PrimeFaces 3.4.2和Facelets合作,並在Tomcat 7中運行。其次,也許最重要的是,上面提供的代碼通過一個標籤包含在更大的xhtml中:

<ui:define name="body"> 
    <rich:panel styleClass="createFormPanel"> 
    <h:panelGroup layout="block" style="margin:0 auto;width:100%;" id="principalPanel"> 
    <div style="height: 665px"><p:tabView id="tabs" widgetVar="tabsView" activeIndex="#{oaBean.activeTab}"> 
     <p:tab id="tab5" title="#{messages['oa.tab.contenido']}"> 
      <h:form id="formTab2"> 
      <ui:include src="/pages/oa/tabContenido.xhtml" /> 
      </h:form> 
     </p:tab> 
    </p:tabView></div> 
    </h:panelGroup> 
    </rich:panel> 
</ui:define> 


在這種情況下,tabContenido.xhtml是包含數據表定義的頁面。沒有包含java代碼,因爲它只是一個具有getter和setter值的bean。如果您需要更多信息,請告訴我。
此致敬禮。

+0

請張貼代碼SSCCE味道。根據目前提供的信息,至少有3個可能的原因,我不知道它是哪一個。至少,與視圖相比,您的模型很可能已經發生了不可比擬的變化。有關創建SSCCE的提示,請閱讀http://stackoverflow.com/tags/jsf/info – BalusC

+0

謝謝@BalusC,我將閱讀該鏈接並編輯帖子 – maxivis

+0

編輯帖子@BalusC,我忘了提到第一個代碼是通過一個標籤包含到另一個文件中的:S – maxivis

回答

1

嘗試添加AJAX事件列和更新孔表,像這樣:

  <p:column headerText="#{messages['documento.orden']}" 
      style="width:25px; text-align: center" id="columnOrden"> 
      <p:inputText id="ordenDocumento" value="#{documento.orden}" 
       disabled="#{documento.eliminado}" style="font-size:0.9em" size="2" 
       validator="floatValidator"> 
       <p:ajax event="change" update="documentoList" /> 
      </p:inputText> 
     </p:column> 
+0

非常感謝,你爲我節省了很多時間 – maxivis

相關問題