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 ..