0

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>
BalusC
  • 992,635
  • 352
  • 3,478
  • 3,452
javaManiac
  • 51
  • 2
  • 7

1 Answers1

0

Remove () from action method

    <p:commandButton value="login" action="#{loginClientBean.valider}" ajax="false"/>

Give name for your managed bean (note it should work without specifying name also)

 @ManagedBean(name="loginClientBean ")
 @SessionScoped
 public class LoginClientBean {
   .....
  }

If you are using JSF 2.2 replace jdk with 1.7 and above .Finally give proper build before deploying

Also have a look into balu c solution https://stackoverflow.com/a/30128396/4036926

Community
  • 1
  • 1
Divagar Haldurai
  • 259
  • 2
  • 3
  • 10
  • Nothing of this all solves the described problem. If parentheses were not supported, a completely different exception would be thrown. Repeating exactly the default name makes also no sense. It's therefore very surprising why this non-working answer is being upvoted. – BalusC Feb 14 '17 at 08:14
  • none of that did solve it my friend my jdk is already 1.7 and i did add the name but it didn't work – javaManiac Feb 14 '17 at 11:56