p:未在bean中设置selectOneMenu值

时间:2013-10-03 13:45:52

标签: jsf primefaces selectonemenu

p:selectOneMenu 中,未在bean中设置loginbranchName值。在具有branchName列表的selectItem中,我使用侦听器从列表中选择值,但未在getLoginBranchId方法中设置值....

<h:outputLabel value="Branch Name:*" style="text-align: left;display: block;" rendered="#{loginBean.userLoggedIn}"/>
                <p:selectOneMenu value="#{loginBean.loginbranchName}"
                    rendered="#{loginBean.userLoggedIn}"
                    style="width:175px;">
                    <f:selectItem itemLabel="Select" itemValue="0" />
                    <f:selectItems value="#{loginBean.branchName}" />
                    <p:ajax event="change" listener="#{loginBean.getLoginBranchId}"/>
                </p:selectOneMenu>

login.java

public String getLoginbranchName() {
    return loginbranchName;
}

public void setLoginbranchName(String loginbranchName) {
    System.out.println("loginbranchName"+loginbranchName);
    this.loginbranchName = loginbranchName;
}
public void getLoginBranchId()
{
    System.out.println("enter into getloginbranchid");
    System.out.println("loginbranchName"+loginbranchName);
    int unitId=loginDAO.getLoginBranchId(loginbranchName);
    System.out.println("unitId"+unitId);
}

1 个答案:

答案 0 :(得分:4)

@BalusC对于上述讨论是正确的,JSF2可以使用列表 SelectItem https://stackoverflow.com/tags/selectonemenu/info我认为您可能会丢失

<h:form> 
</h:form>

标签