我想将valueValue赋予bean。当我在cellEditor中添加值并单击保存按钮ratedValue get null。
<p:dataTable id="manager" var="item" value="#{employeedaBean.userList}"
paginator="true" rows="10"
paginatorTemplate="{RowsPerPageDropdown} {FirstPageLink} {PreviousPageLink} {CurrentPageReport} {NextPageLink} {LastPageLink}"
rowsPerPageTemplate="2,5,10,15"
editable="true" editMode="cell" widgetVar="carsTable"
lazy="true" emptyMessage="No Customers found with given criteria">
<f:facet name="header">
Employee
</f:facet>
<p:column headerText="Rated">
<p:cellEditor>
<f:facet name="output"><h:outputText value="#{item.ratedValue}" /></f:facet>
<f:facet name="input">
<p:selectOneMenu value="#{item.ratedValue}" style="width:100%">
<f:selectItems value="#{employeedaBean.rateValueMany}"/>
</p:selectOneMenu>
</f:facet>
</p:cellEditor>
</p:column>
</p:dataTable>
答案 0 :(得分:1)
您需要首先定义一个ajax侦听器:(在您的情况下,例如在标题部分下方)
<p:ajax event="rowEdit" listener="#{listener.onEdit}" update=":manager" />
然后,您需要定义:(您已经 - rowEditor或cellEditor)
<p:column styleClass="admin-columns-text">
<p:rowEditor/> or <p:cellEditor/>
</p:column>
然后在您的侦听器方法中,您可以检索新值,如下所示:
(如果您使用RowEditEvent
)
public void onEdit(RowEditEvent event) {
User userChanged = (User) event.getObject();
}
(如果您使用CellEditEvent
)
public void onEdit(CellEditEvent event) {
User userOld = (User) event.getOldValue();
User userNew = (User) event.getNewValue();
}