Java jsf下拉列表返回托管bean中的选定值null

Java jsf下拉列表返回托管bean中的选定值null,java,jsf,Java,Jsf,我使用converter在xhtml中为下拉菜单选择一个菜单,但当我试图在backingbean中显示所选值时,它返回null。我尝试过使用带有update和actionListener属性的ajax标记,但仍然是一样的。如何访问所选值。。。。 我还使用session变量来获取login person对象 @Xhtml File <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.or

我使用converter在xhtml中为下拉菜单选择一个菜单,但当我试图在backingbean中显示所选值时,它返回null。我尝试过使用带有update和actionListener属性的ajax标记,但仍然是一样的。如何访问所选值。。。。 我还使用session变量来获取login person对象

@Xhtml File

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui" >
<h:body>
    <ui:composition template="/pages/protected/templates/master.xhtml">
        <ui:define name="divMain">
            <h:form id="fileDetailsForm">

                <p:commandButton immediate="true" ajax="false" action="#{fileMB.onBtnCancel}" value="#{bundle.back}"/>

                <p:panel id="toggleable" header="File Details" toggleable="true" closable="false" toggleSpeed="500" closeSpeed="500" widgetVar="panel" style="margin-bottom:20px">
                    <p:panelGrid  columns="2" columnClasses="label,value">

                        <h:outputText value="#{bundle.subject}" />
                        <h:outputText value="#{fileMB.selectedFile.subject}" />

                        <h:outputText value="#{bundle.fileRefNo}" />
                        <h:outputText value="#{fileMB.selectedFile.fileRefNo}" />

                        <h:outputText value="#{bundle.description}" />
                        <h:outputText value="#{fileMB.selectedFile.description}" />

                        <h:outputText value="#{bundle.creationDate}" />
                        <h:outputText value="#{fileMB.selectedFile.creationDate}" />

                        <h:outputText value="#{bundle.priority}" />
                        <h:outputText value="#{fileMB.selectedFile.priority}" />

                        <h:outputText value="#{bundle.classification}" />
                        <h:outputText value="#{fileMB.selectedFile.classification}" />

                        <h:outputText value="#{bundle.created} #{bundle.person}" />
                        <h:outputText value="#{fileMB.selectedFile.createdPerson}" />

                        <h:outputText value="#{bundle.submitStatus}" />
                        <h:outputText value="#{fileMB.selectedFile.submitStatus}" />

                        <h:outputText value="#{bundle.oldFileRefNo}" />
                        <h:outputText value="#{fileMB.selectedFile.oldFileRefNo}" />



        <h:outputText value="#{bundle.person}" />
                        <p:selectOneMenu value="#{fileMB.person}" required="true" label="#{bundle.reportingto}" converter="personConverter">  
                            <f:selectItem itemLabel="[Select]" noSelectionOption="true" itemValue="" />
                            <f:selectItems value="#{personMB.persons}" var="orgType" itemLabel="#{orgType.firstName}" itemValue="#{orgType}"/>  

                        </p:selectOneMenu>  


              <p:commandButton value="#{bundle.create}" ajax="true" immediate="true" update="@form" action="#{fileMB.forward}" />
                  </h:panelGrid>


                </p:panel>

            </h:form>
                    <ui:include src="/pages/protected/filling/File/CreateComentDialog.xhtml" />  

                    </ui:define>
    </ui:composition>
</h:body>
</html>

当您为CommandButton设置immdaite=true属性时,您将强制跳过JSF过程生命周期中的几个阶段。其中之一是更新模型阶段。删除immediate=true按钮属性或将其设置为false默认值。

我已更改immediate=false,并尝试删除整个属性,但仍然无效。返回值={fileMB.person}中的空值。事实上,它没有任何价值。。未选择咆哮消息类型:personlabel中无值
@Backing bean

package com.managedBean.Filling;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.faces.event.ActionEvent;
import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;


import com.controller.Controller;
import com.managedBean.BaseMB;
import com.model.um.Designation;
import com.model.um.Organization;
import com.model.um.Person;


@ManagedBean(name="fileMB")
@SessionScoped
public class FileMB extends BaseMB implements Serializable
{
    public static final long serialVersionUID = 1L;
    public static final Logger log = LogManager.getLogger(FileMB.class.getName());


    private File info;
    private File file;
    private Person person;
    private List<Person> personList;
    private File selectedFile;
    private Person per;
    long id;



   FacesContext cont=FacesContext.getCurrentInstance();
    HttpServletRequest req=(HttpServletRequest)cont.getExternalContext().getRequest();


    {
    per=(Person) req.getSession().getAttribute("loginPerson");

    }
        public Person getPer() {
        return per;
    }

    public void setPer(Person per) {
        this.per = per;
    }

    public File getSelectedFile() {
        return selectedFile;
    }

    public void setSelectedFile(File selectedFile) {
        this.selectedFile = selectedFile;
    }

    public List<File> getFileList() {
        id = per.getPersonId();
        System.out.println(id);
        this.fileList = controller.getSpecificFiles(id);
        return fileList;
    }

    public void setFileList(List<File> fileList) {
        this.fileList = fileList;
    }

    public Person getPerson() {
        return person;
    }

    public void setPerson(Person person) {
        this.person = person;
    }

    public List<Person> getPersonList() {
        this.personList = controller.getAllPersons();
        return personList;
    }

    public void setPersonList(List<Person> personList) {
        this.personList = personList;
    }




    public File getFile() {
        return file;
    }

    public void setFile(File file) {
        this.file = file;
    }

    public File getInfo() {
        return info;
    }

    public void setInfo(File info) {
        this.info = info;
    }


    public void forward()
    {
            System.out.println("else");

            System.out.println(person);
            System.out.println(person.getFirstName());


        }
output:
else
com.model.um.Person@adf429
null