JSF支持bean将该属性设置为null

时间:2013-04-23 13:14:46

标签: jsf-2

我正在尝试从控制器bean访问表单支持bean数据。来自表格的价值   在bean中设置但是当我试图从控制器bean访问它时,值为null。空值在createTicket方法中:---> ticketData.getSummary());

/*from data bean everything sets here*/
    import java.io.Serializable;
     import java.util.Date;
    import java.util.List;
     @SuppressWarnings("PMD")
    @ManagedBean(name = "createTicketModelData")
    @SessionScoped
    public class CreateTicketModelData implements CreateTicketData, Serializable {

    private static final long serialVersionUID = 1L;

    protected String incidentType;

    private TicketId ticketId;

    protected UserId receiverId;

    protected String summary;
    private String description;
    private String asset;
    private Date dateTime;
    protected Date reported;
    private Date dateChangeNeeded;
    private String priority;
    protected List<Attachment> attachments;

    public void setAttachments(final List<Attachment> attachments) {
        this.attachments = attachments;
    }

    protected String orgUnit;
    protected String location;

    protected String costCenter;
    private Type type = Type.INCIDENT;
    private String severity;

    @Override
    public String getAsset() {
        return asset;
    }

    @Override
    public List<Attachment> getAttachments() {
        return attachments;
    }

    public String getCostCenter() {
        return costCenter;
    }
.....//getter seters
----------------------------------------------------------------------

    /*this is the controller bean where i am not able to get the form data values*/

   @ManagedBean(name = "createTicketBaseBean")
    @SessionScoped
        public class CreateTicketBaseBean implements Serializable {

    private static final long serialVersionUID = 1L;
    private static final transient Logger LOGGER =    LoggerFactory.getLogger(CreateTicketBaseBean.class);



    @ManagedProperty(value = "#{ticketData}")
    private transient CreateTicketModelData ticketData;

    @ManagedProperty(value = "#{ticketingService}")
    transient TicketingService dispatcher;


    @PostConstruct
    protected void init() {
        this.workplaceBean = JSFUtils.findBean("selectWorkplaceComponentBean");
        this.selectUserBean = JSFUtils.findBean("selectUserBean");


    }

    public void createTicket(final ActionEvent event) {
        Response response = null;

        System.out.println("ticket summary------------" + ticketData.getSummary());
        setTicketData();
        LOGGER.info("Incident type in ticketdatabean---->" + incidentType);
        try {
            response = dispatcher.createTicket(ticketData);
        } catch (Exception e) {
            LOGGER.error(e);
            FacesMessageUtil.addGlobalUnexpectedErrorMessage();
        }

        LOGGER.info("Response is---->" + response.getTicketId());
        ticketId = response.getTicketId();
    }

1 个答案:

答案 0 :(得分:0)

尝试更改注释@ManagedProperty(value =“#{ticketData}”)中的值,以使用已使用“createTicketModelData”注释它的bean名称。