1

我已经按照这个链接在 p:datatable 中使用多个值的选择

http://www.primefaces.org/showcase/ui/datatableRowSelectionRadioCheckbox.jsf

现在,当我从中选择多个值并单击表单中的按钮时,它应该调用 bean 中的一个方法,该方法工作正常。但所选值列表为空。我在这里阅读了帖子,但没有找到解决方案。我也尝试了不同的方法,但没有成功。

JSF 代码:

<p:dataTable value="#{deviceController.devicesModel}" var="deviceList" widgetVar="deviceTable" selection="#{deviceController.selectedDevices}>                       
<p:column  sortBy="#{deviceList.manufacturerSerialNum}" filterBy="#{deviceList.manufacturerSerialNum}">
<f:facet name="header">
<h:outputText value="Manufacturer Serial No"/>
</f:facet>
<h:outputText value="#{deviceList.manufacturerSerialNum}" />  
</p:column>
<p:column selectionMode="multiple">
 <f:facet name="header">
<h:outputText value="#{bundle.ListLaptopTitle_inService}"/>
</f:facet>
</p:column>
</p:dataTable> 
<p:commandButton action="#{deviceController.update(deviceController.selectedDevices)}" value="Submit Request" style="margin-top: 20px"/>

Bean中的代码:

公共字符串更新(列表更新设备){

    try {

        for(Device d:updateDevice)
        {
        getFacade().edit(d);
        }
       //message which indiactes device update is successful
        return "/example.html";
    } catch (Exception e) {
        //handling exception
        return null;
    }
}

因此,我从页面中传递了 deviceController.selectedDevices 的值,该值在检查时为空。

谢谢

4

0 回答 0