I am getting below error when I run my login jsf page.
I think that my valider()
function in my managed Bean is the issue but I didn't find the way
Authenticate function in my ejb:
@Override
public Client authentificate(String login, String pwd) {
Client client=null;
Query query=entityManager.createQuery("select c from Client c where c.login=:l and c.pwd=:p");
query.setParameter("l", login).setParameter("p",pwd);
try {
client=(Client) query.getSingleResult();
} catch (Exception e) {
client=null;
}
return client;
}
Managed bean:
@ManagedBean
@SessionScoped
public class LoginClientBean {
@EJB
GestionClientLocal local;
private String login;
private String pwd;
private boolean connected;
public static Client client;
public String getLogin() {
return login;
}
public void setLogin(String login) {
this.login = login;
}
public String getPwd() {
return pwd;
}
public void setPwd(String pwd) {
this.pwd = pwd;
}
String message=null;
public String getMessage() {
return message;
}
public void setMessage(String message) {
this.message = message;
}
public boolean isConnected() {
return connected;
}
public void setConnected(boolean connected) {
this.connected = connected;
}
public Client getClient() {
return client;
}
public String valider(){
String nav =null;
client=local.authentificate(login, pwd);
if (client != null){
nav="/pages/yes?faces-redirect=true";
}else {
nav="/pages/no?faces-redirect=true";
}
return nav;
}
public String deconnexion(){
FacesContext.getCurrentInstance().getExternalContext().getSessionMap().clear();
return "/pages/login?faces-redirect=true";
}
}
JSF Page:
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:pt="http://xmlns.jcp.org/jsf/passthrough"
xmlns:p="http://primefaces.org/ui"
xmlns:f="http://xmlns.jcp.org/jsf/core"
xmlns:jsf="http://xmlns.jcp.org/jsf"
xmlns:h="http://xmlns.jcp.org/jsf/html"
xmlns:ui="http://xmlns.jcp.org/jsf/facelets">
<h:head>
<title>Flate Signup And Login Form with Flat Responsive template :: w3layouts</title>
<meta name="viewport" content="width=device-width, initial-scale=1"></meta>
<h:outputStylesheet library="css" name="style.css"></h:outputStylesheet>
<h:outputScript type="application/x-javascript"> addEventListener("load", function() { setTimeout(hideURLbar, 0); }, false); function hideURLbar(){ window.scrollTo(0,1); } </h:outputScript>
</h:head>
<h:body>
<h:form>
<h:panelGrid columns="2">
<h:outputText value="login" />
<p:inputText value="#{loginClientBean.login}" />
<h:outputText value="password" />
<p:password value="#{loginClientBean.pwd}" />
<p:commandButton value="login" action="#{loginClientBean.valider()}" ajax="false"/>
</h:panelGrid>
</h:form>
</h:body>
</html>