传递Managedbean属性

时间:2019-07-16 10:28:10

标签: jsf-2.2

我有两个会话作用域的Bean,我需要通过f:setPropertyActionListener在它们之间传递值,但是我无法从应收端读取它。

<p:selectOneListbox style="height: 100%; width: 100%" id="lstSubject" required="true" requiredMessage="Please select any Subject" 
    value="#{chooseSubExamManagedBean.subId}" >
    <f:selectItems value="#{chooseSubExamManagedBean.mapSubjects}" />
</p:selectOneListbox>                    

用户选择主题,我必须将此ID从p:command按钮传递给另一个bean

<p:commandButton  id="cmdProceed" value="Proceed" action="#{chooseSubExamManagedBean.gotoFillMarks}" >
    <f:setPropertyActionListener target="#{fillMarksManagedBean.subId}" value="#{chooseSubExamManagedBean.subId}" />
</p:commandButton>

托管bean fillMarksManagedBean

@Named(value = "fillMarksManagedBean")
@javax.enterprise.context.SessionScoped
public class FillMarksManagedBean implements Serializable{
private int SubId;
private String ExamDetail;

    public void setSubId(int SubId) {
        this.SubId = SubId;
    }

    public int getSubExamId() {
        return SubExamId;
    }

并在其中使用该subId

@PostConstruct
    public void init() {

    ExamDetail = clsFillMarks.getExamDetail(SubId);
}
...   

我该怎么做? 预先感谢

0 个答案:

没有答案