[英]p:inputText in p:dataTable not setting the value in the bean
我正在嘗試實現一個dataTable,其中包含(除其他事項外)帶有textInput的列,以便我可以修改Bean中的字符串值。 我的問題是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。 如果您需要更多信息,請告訴我。
問候。
嘗試將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>
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.