通过返回null的setPropertyActionListener传递对象

时间:2014-04-08 23:13:16

标签: jsf primefaces

在我的应用程序中,当用户登录时我需要将他的信息发送到MenuManagedBean来识别要显示的菜单(我正在尝试使用primefaces编程菜单示例)但是当我尝试这样做时,发送给managedBean的对象通过setPropertyActionListener始终为null,我无法弄清楚我的错在哪里。

这是我的jsf页面代码

                 <h:form class="contact-us">
            <h1 style="font-family: 'Segoe UI light'">GED</h1>
            <div style="margin-left: 33%">

                <br></br> <br></br>
            </div>
            <div style="margin-left: 25%">
                <p:inputText id="login" placeholder="login ..." required="true"
                    requiredMessage="Login obligatoire" value="#{persMb.personnel.login}">
                    <p:message for="login" display="text" />
                </p:inputText>
                <p:inputText type="password" id="password"
                    placeholder="mot de passe ..." required="true"
                    requiredMessage="Mot de passe obligatoire" value="#{persMb.personnel.motDePasse}">
                    <p:message for="password" display="text" />
                </p:inputText>
                <br /> <br />
            </div>
            <p:commandButton styleClass="font-custom"
                value="Connexion" ajax="false" action="#{persMb.checkValidUser}" process="@this">
                <f:setPropertyActionListener target="#{menuMb.role}"
                            value="#{persMb.personnel.role}"  />
                </p:commandButton>

        </h:form>

这是我的MenuBean代码

                private MenuModel model;
private Personnel personnel = new Personnel();
private Role role= new Role();
    private PersonnelDao pDao = new PersonnelDao();
public MenuMb() {
System.out.println(" role ="+role.getIdRole()); 
if(role.getIdRole()==1)
{
    model = new DefaultMenuModel();
DefaultSubMenu firstSubmenu = new DefaultSubMenu("Services");
DefaultMenuItem item = new DefaultMenuItem("Internes");
item.setUrl("http://localhost:8080/GED/Service/servicesinter.xhtml");
firstSubmenu.addElement(item);
item = new DefaultMenuItem("Externes");
item.setUrl("http://localhost:8080/GED/Service/serviceexter.xhtml");
firstSubmenu.addElement(item);
model.addElement(firstSubmenu);
DefaultSubMenu secondSubmenu = new DefaultSubMenu("Personnels");
item = new DefaultMenuItem("Personnels");
item.setUrl("http://localhost:8080/GED/Personnel/personnel.xhtml");
secondSubmenu.addElement(item);
model.addElement(secondSubmenu);
DefaultSubMenu thirdSubmenu = new DefaultSubMenu("Etablissements");
item = new DefaultMenuItem("Etablissements");
item.setUrl("http://localhost:8080/GED/Personnel/personnel.xhtml");
thirdSubmenu.addElement(item);
model.addElement(thirdSubmenu);
DefaultSubMenu fourthSubmenu = new DefaultSubMenu("Courriers");
item = new DefaultMenuItem("Arrivés");
item.setUrl("#");
fourthSubmenu.addElement(item);
item = new DefaultMenuItem("Départs");
item.setUrl("#");
fourthSubmenu.addElement(item);
model.addElement(fourthSubmenu);
DefaultSubMenu fifthSubmenu = new DefaultSubMenu("Paramétrage");
item = new DefaultMenuItem("Paramétrage");
item.setUrl("#");
fifthSubmenu.addElement(item);
model.addElement(fifthSubmenu);
}

我正在使用jsf2.2。

0 个答案:

没有答案