0

I'm making a software practice for college and I'm trying to make a login form, but the managed bean seems that does not receive the user and password values.

Here is the view:

    <ui:define name="content">
      <h:form align="center" bgcolor="#E1E1E1"> 
        <h:outputText value="Correu electrònic:  "/>
        <h:inputText id = "email" value="#{login.email}" required="true"/> 
        <br/><br/>
        <h:outputText value="Contrasenya:  "/>
        <h:inputText type="password" id = "password" value="#{login.password}" required="true"/> 
        <br/><br/>
        <h:commandButton value="Login" immediate ="true" action="#{login.login}"/>
      </h:form>     
    </ui:define>

This is my ManagedBean:

package managedbean;

import java.io.Serializable;

import ejb.UserFacadeRemote;

import javax.ejb.EJB;
import javax.faces.application.FacesMessage;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletRequest;

@ManagedBean(name = "login")
@SessionScoped
public class LoginMBean implements Serializable{

    private static final long serialVersionUID = 1L;    

    @EJB

    private UserFacadeRemote userRemote;

    private String password;
    private String email;

    public LoginMBean() throws Exception { }

    public String getPassword() {
        return password;
    }

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

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String login() throws Exception {
        System.out.println("User 1 - " + this.email + " P - " + this.password);
    }

The answer in console when I push the login button is:

11:58:45,997 INFO [stdout] (http-localhost-127.0.0.1-8080-3) User 1 - null P - null

ElXaxe
  • 15
  • 7
  • I've been testing other ManagedBeans that receive values from a post and it's happening the same with all of them – ElXaxe Jan 05 '16 at 12:37
  • What is the outcome, when `immediate ="true"` is removed from the given ``? Check by removing the master template i.e. create another XHTML file which does not involve the template mess. (This is off-topic for the current question but needs to be considered : I do not like using a session scoped bean for things login as it is not required for this functionality. There is no need to use `. There is a standard JSF component called `` for a password field. Attributes like `bgcolor`, `align` aren't supported by `` nor `
    `)
    – Tiny Jan 05 '16 at 14:20
  • Yeah, the real problem was immediate = "true". THANKS! – ElXaxe Jan 05 '16 at 15:09

0 Answers0