使用时<p:rowEditor>
,如何检索已编辑单元格的行索引?
以下是相关代码:
<p:dataTable id="datasetParamDt" var="datasetParam" value="#{projectCampaignManagementMB.allParametersList}" editable="true" rowIndexVar="rowIndex">
<p:ajax event="rowEdit" listener="#{projectCampaignManagementMB.onParameterValueEdit}" update=":campaignForm:growl" />
<p:ajax event="rowEditCancel" listener="#{projectCampaignManagementMB.onParameterValueCancel}" update=":campaignForm:growl"/>
<p:column headerText="Value">
<p:cellEditor>
<f:facet name="output">
<h:outputText value="#{projectCampaignManagementMB.paramValue}" />
</f:facet>
<f:facet name="input">
<p:inputText value="#{projectCampaignManagementMB.paramValue}" />
</f:facet>
</p:cellEditor>
</p:column>
<p:column headerText="Options" style="width:50px">
<p:rowEditor />
</p:column>
</p:dataTable>
在简单的数据表中,我曾经使用<f:param>
in a<p:commandLink>
如下:
<f:param name="index" value="#{rowIndex}" />
但是,在我的情况下<p:rowEditor>
,当用户验证方法中的编辑值时,如何获取行索引onParameterValueEdit()
?
public void onParameterValueEdit(RowEditEvent event) {
int index = ... // index of the row to which the edited cell belongs
parametersValue.set(Integer.parseInt(index),paramValue);
}