0

I am trying to create a login page for my application but i am stuck on the very first step. My form is working fine before using session facade in my bean, after adding session facade i got property not found exception:

My page is:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui">

    <f:view contentType="text/html">
        <h:head>
            <f:facet name="first">
                <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
                <title>PrimeFaces</title>
            </f:facet>
        </h:head>

        <h:body>
            <h:form>
            <p:panelGrid columns="2">
                <p:outputLabel value ="Username"/> <p:inputText id="userName" value="#{loginBean.user}"/> 
                <p:outputLabel value ="Password"/> <p:inputText id="password" value="#{loginBean.password}"/>
            </p:panelGrid>
                <p:commandButton value="Login" actionListener="#{loginBean.doLogin}"/>
            </h:form>
        </h:body>

    </f:view>
</html>

Working Bean Code is :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Beans;

import entities.Program;
import entities.ProgramFacade;
import entities.ProgramFacadeLocal;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import javax.annotation.ManagedBean;
import javax.ejb.EJB;
import javax.faces.event.ActionEvent;

/**
 *
 * @author Salman Ahmed Ansari
 */
@Named(value = "loginBean")
@SessionScoped
public class LoginBean implements Serializable {

    /**
     * Creates a new instance of LoginBean
     */
    private String user;
    private String password;

    public String getUser() {
        return user;
    }

    public String getPassword() {
        return password;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void doLogin(ActionEvent listener){
        System.out.println(user);
        System.out.println(password);
    }

    public LoginBean() {

    }
}

and not working bean code is :

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Beans;

import entities.Program;
import entities.ProgramFacade;
import entities.ProgramFacadeLocal;
import javax.inject.Named;
import javax.enterprise.context.SessionScoped;
import java.io.Serializable;
import javax.annotation.ManagedBean;
import javax.ejb.EJB;
import javax.faces.event.ActionEvent;

/**
 *
 * @author Salman Ahmed Ansari
 */
@Named(value = "loginBean")
@SessionScoped
public class LoginBean implements Serializable {
    @EJB
    private ProgramFacade programFacade;

    /**
     * Creates a new instance of LoginBean
     */
    private String user;
    private String password;

    public String getUser() {
        return user;
    }

    public String getPassword() {
        return password;
    }

    public void setUser(String user) {
        this.user = user;
    }

    public void setPassword(String password) {
        this.password = password;
    }

    public void doLogin(ActionEvent listener){
        System.out.println(user);
        System.out.println(password);
    }

    public LoginBean() {

    }
}

What triggers this exception?

Thanks in Advance ..

Philip G
  • 4,098
  • 2
  • 22
  • 41
  • 1
    Please write down stacktrace of your exception by catching it and printing it as exception.printStackTrace() – Jitesh Mar 15 '14 at 13:57
  • Three small hints; the `value` attribute for `@Names` is redundant. The value you used is already the default. It's highly unlikely that `@SessionScoped` is the best scope for the problem you seem to be trying to solve. You'll run into issues when the same page is opened in multiple tabs. Most likely you want `@ViewScoped` here. The login action seems to be the primary action. By convention it's better to use a straight `action` for this, not an `actionListener`. – Arjan Tijms Mar 16 '14 at 07:16

0 Answers0