Java Primefaces SelectCheckBox菜单空值

Java Primefaces SelectCheckBox菜单空值,java,jsf,jsf-2,primefaces,Java,Jsf,Jsf 2,Primefaces,我试图从SelectCheckBox菜单中获取所选值,但在控制台中得到的只是空值。它也不适用于selectOneMenu。这是我的jsf表单: <h:form id="mmaster"> <p:dataTable value="#{devicesBean.devices}" var="dev" widgetVar="dt" border="1" paginator="true"

我试图从SelectCheckBox菜单中获取所选值,但在控制台中得到的只是空值。它也不适用于selectOneMenu。这是我的jsf表单:

<h:form id="mmaster">
        <p:dataTable
        value="#{devicesBean.devices}" 
        var="dev"
        widgetVar="dt"
        border="1" 
        paginator="true"
        paginatorPosition="top"
        rows="10"
        >
            <f:facet name="header">Devices</f:facet>
                        <p:column headerText="UDN" sortBy="#{dev.deviceUDN}" filterBy="#{dev.deviceUDN}" filterMatchMode="contains" emptyMessage="No Devices Found">
                <h:outputText value="#{dev.deviceUDN}" />
            </p:column>
            <p:column headerText="FriendlyName" sortBy="#{dev.deviceFriendlyName}" filterBy="#{dev.deviceFriendlyName}" filterMatchMode="contains">
                <h:outputText value="#{dev.deviceFriendlyName}" />
            </p:column>
            <p:column headerText="Model" sortBy="#{dev.deviceModel}" filterBy="#{dev.deviceModel}" filterMatchMode="contains">
                <h:outputText value="#{dev.deviceModel}" />
            </p:column>
            <p:column headerText="Manufacturer" sortBy="#{dev.deviceManufacturer}" filterBy="#{dev.deviceManufacturer}" filterMatchMode="contains">
                <h:outputText value="#{dev.deviceManufacturer}" />
            </p:column>
            <p:column headerText="Type" sortBy="#{dev.deviceType}" filterBy="#{dev.deviceType}" filterMatchMode="contains">
                <h:outputText value="#{dev.deviceType}" />
            </p:column>
        <p:column headerText="Actions">
        <p:selectCheckboxMenu value="#{devicesBean.selectAnnotations}">
        <f:selectItems value="#{devicesBean.annotations}" />
        </p:selectCheckboxMenu>           
        </p:column>
        <p:column>
        <p:commandButton value="Annotate" action="#{devicesBean.doSave}" process="@this">
        <f:setPropertyActionListener value="#{dev}" target="#{devicesBean.device}" />
        </p:commandButton> 
        </p:column>
    </p:dataTable>
</h:form>

装置
我想知道bean的范围是否有问题,这是我的托管bean:

@ManagedBean
public class DevicesBean implements Serializable {

    private static final long serialVersionUID = 1L;
    private List<Device> devices;
    private List<String> annotations;
    private List<String> selectAnnotations = new ArrayList<String>();
    private Device device;

    @EJB
    IOntoProcessor iop;
    @EJB
    IDevicesDao idd;

    public DevicesBean() {
    }

    @PostConstruct
    public void init() {
        setDevices(idd.getAllDevices());
        setAnnotations(iop.getAllAnnotations());
    }

    public List<Device> getDevices() {
        return devices;
    }

    public void setDevices(List<Device> devices) {
        this.devices = devices;
    }

    public List<String> getAnnotations() {
        return annotations;
    }

    public void setAnnotations(List<String> annotations) {
        this.annotations = annotations;
    }

    public Device getDevice() {
        return device;
    }

    public void setDevice(Device device) {
        this.device = device;
    }

    public List<String> getSelectAnnotations() {
        return selectAnnotations;
    }

    public void setSelectAnnotations(List<String> selectAnnotations) {
        this.selectAnnotations = selectAnnotations;
    }

    public void doSave() {
        System.out.println(selectAnnotations);
        System.out.println(device);
        selectAnnotations = new ArrayList<String>();
    }

}
@ManagedBean
公共类DeviceBean实现了可序列化{
私有静态最终长serialVersionUID=1L;
私有列表设备;
私有列表注释;
private List selectAnnotations=new ArrayList();
专用设备;
@EJB
离子处理器iop;
@EJB
IDevicesDao idd;
公共设备bean(){
}
@施工后
公共void init(){
setDevices(idd.getAllDevices());
setAnnotations(iop.getAllAnnotations());
}
公共列表getDevices(){
返回装置;
}
公用设备(列出设备){
这个。设备=设备;
}
公共列表getAnnotations(){
返回注释;
}
公共注释(列表注释){
这个注释=注释;
}
公共设备getDevice(){
返回装置;
}
公共无效设置设备(设备){
这个装置=装置;
}
公共列表getSelectAnnotations(){
返回selectannotation;
}
public void setSelectAnnotations(列表selectAnnotations){
this.selectAnnotations=selectAnnotations;
}
公共无效数据存储(){
System.out.println(selectAnnotations);
系统输出打印LN(设备);
selectAnnotations=new ArrayList();
}
}

您正试图通过带有值注释的按钮提交表单,该按钮已指定为仅处理自身:

这将只处理按钮及其关联的表单参数,而不处理表单中的其他元素

<p:commandButton value="Annotate" action="#{devicesBean.doSave}" process="@this">
    <f:setPropertyActionListener value="#{dev}" target="#{devicesBean.device}" />
</p:commandButton> 

第二,声明您的托管bean范围:无论是
@RequestScope
还是
@SessionScoped
都可以正常工作。

我做了上述所有工作,但出于某种奇怪的原因,我仍然得到空值,而不是所选的项。
<p:commandButton value="Annotate" action="#{devicesBean.doSave}" process="@form">
    <f:setPropertyActionListener value="#{dev}" target="#{devicesBean.device}" />
</p:commandButton>