0

I have been trying to get the fields from the xhtml page and store it in a bean. Then, load the inputted fields into the output form.

Login.java (Managed Bean)

package com.ose.bookstore.model.entity;

import java.io.Serializable;

import javax.faces.bean.ManagedBean;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;

/**
 * Entity implementation class for Entity: Login
 *
 */
@Entity
@ManagedBean(name="login")
public class Login implements Serializable {

    private static final long serialVersionUID = 1L;

    @Id
    @GeneratedValue
    private int loginId;
    private String userEmail;
    private String password;
    private String secPassword;
    public String getUserEmail() {
        return userEmail;
    }
    public void setUserEmail(String userEmail) {
        this.userEmail = userEmail;
    }
    public String getPassword() {
        return password;
    }
    public void setPassword(String password) {
        this.password = password;
    }
    public String getSecPassword() {
        return secPassword;
    }
    public void setSecPassword(String secPassword) {
        this.secPassword = secPassword;
    }
    public int getLoginId() {
        return loginId;
    }
    public void setLoginId(int loginId) {
        this.loginId = loginId;
    }
}

Login.xhtml(Input Form)

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p ="http://primefaces.org/ui">

<body>

    <h:form>
        <h:panelGrid>

            <h:outputLabel value="User Name" />
            <h:inputText value="#{login.userEmail}" />

            <h:outputLabel value="Password" />
            <h:inputText value="#{login.password}" />

            <h:outputLabel value="sec Password" />
            <p:inputText value="#{login.secPassword}" />

            <h:commandButton value="Sign In"
                action="confirmation.xhtml" />
        </h:panelGrid>
    </h:form>

</body>
</html>

Confirmation.xhtml

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core"
    xmlns:p ="http://primefaces.org/ui">

<body>

    <h:form>
        <h:panelGrid>

            <h:outputLabel value="User Name" />
            <h:outputText value="#{login.userEmail}" />

            <h:outputLabel value="Password" />
            <h:outputText value="#{login.password}" />

            <h:outputLabel value=" sec Password" />
            <h:outputText value="#{login.secPassword}" />

        </h:panelGrid>

    </h:form>

</body>
</html>

Every time I run this, I get this error : javax.el.PropertyNotFoundException: /Login.xhtml @16,46 value="#{login.userEmail}": Target Unreachable, identifier 'login' resolved to null

How to fix this error? Is there any problem with the code?

Konstantin Yovkov
  • 59,030
  • 8
  • 92
  • 140
Nishant
  • 432
  • 2
  • 6

0 Answers0