ManagedBean does not save data in setters

0

I am working with a JSF project in which we use several ManagedBean (1 for user login, another for user pre-registration and the last one for employee registration) The problem is that my login ManagedBean serves perfectly (it recognizes if there are saved users) but when going to the pre-registration page the managedBean in charge of saving the data that the user enters in the pre-registration form does not save anything (I print the variable after being "saved" and does not yield any results) Annex fragments of my code:

JSF:

                            <p:outputLabel value="Nombre:">
                                <p:inputText id="nombre" rendered="true" value="#{registro.nombre}"/>
                            </p:outputLabel>
                            <p:outputLabel value="Apellido Paterno:">
                                <p:inputText id="apaterno" rendered="true" value="#{registro.ap}"/>
                            </p:outputLabel>
                            <p:outputLabel value="Apellido Materno:">
                                <p:inputText id="amaterno" rendered="true" value="#{registro.am}"/>
                            </p:outputLabel>
                            <p:outputLabel value="Correo:">
                                <p:inputText id="correo" validatorMessage="Correo no valido" value="#{registro.email}">

                                    <p:clientValidator event="blur"/>
                                    <p:tooltip for="correo" value="Ingresa el Correo"/>
                                    <p:watermark for="correo" value="[email protected]"/>
                                    <p:message for="correo" style="color: red"/>
                                </p:inputText>
                            </p:outputLabel>
                        </h:panelGrid>
                        <br/>
                        <p:commandButton value="Guardar" action="#{registro.registrar()}"/>

preRegisterBean:

    @ManagedBean(name = "registro", eager = true)
    @ApplicationScoped
    public class preRegistroBean {

        private String mySh;
        private String ap;
        private String am;
        private String nombre;
        private String email;
    public String getNombre() {
        return nombre;
    }

    public void setNombre(String nombre) {
        this.nombre = nombre;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }
//Todos los demas getters & setters
public String registrar() {
    FacesContext context = FacesContext.getCurrentInstance();
    String cadena = "";
    System.out.println(email);
    userPojo = userFacade.buscaUserstemp(email);
    if (userPojo == null) {
        String hash = generaHash();
        String numAlea = numAleatorio();
        String pwd = generaPwdTemp(numAlea);
        userPojo = new UserstempPojo(ap, am, nombre, email, pwd, hash, 0, 0);
        userFacade.crearUserTemp(userPojo);
        context.addMessage(cadena, new FacesMessage(FacesMessage.SEVERITY_INFO, "Se ha creado el registro, se le enviara correo", "Registrado"));
    } else {
        context.addMessage(cadena, new FacesMessage(FacesMessage.SEVERITY_ERROR, "Ya existe un usuario con ese correo,\n solicite olvidar contraseña en index", "Error"));
    }
    return cadena;
}

I do not know if anyone could help me see why the Setters do not work. Thanks and regards. ADDITIONAL NOTES: At the beginning the class only had annotation @ManagedBean and @RequestScoped changed to @ApplicationScoped to see if there was a change, but it had the same results, in addition I also attach the commandLink that is used to go from the login page to the page of pre registration:

<p:commandLink value="Preregistro" action="Preregistro"/>

EDIT: I also upload the complete xhtml of the pre-registration page:

<?xml version='1.0' encoding='UTF-8' ?>

<f:view contentType="text/html">
    <h:head>
        <f:facet name="first">
            <meta content='text/html; charset=UTF-8' http-equiv="Content-Type"/>
            <ui:define name="titulo"/>
        </f:facet>
    </h:head>

    <h:body>
        <ui:composition template="Templates/Master.xhtml">
            <ui:define name="header">
                <ui:include src="/Templates/headerDos.xhtml"/>
            </ui:define>
            <ui:define name="izquierdo">
                <ui:include src="/Templates/izquierdoOtro.xhtml"/>
            </ui:define>
            <ui:define name="content">
                <h:form>
                    <p:messages id="messages" showDetail="true" autoUpdate="true" closable="true"/>
                    <div align="center">
                        <h2>Preregistro</h2>
                        <h:panelGrid columns="1" cellpadding="10">
                            <p:outputLabel value="Nombre:">
                                <p:inputText id="nombre" rendered="true" value="#{registro.nombre}"/>
                            </p:outputLabel>
                            <p:outputLabel value="Apellido Paterno:">
                                <p:inputText id="apaterno" rendered="true" value="#{registro.ap}"/>
                            </p:outputLabel>
                            <p:outputLabel value="Apellido Materno:">
                                <p:inputText id="amaterno" rendered="true" value="#{registro.am}"/>
                            </p:outputLabel>
                            <p:outputLabel value="Correo:">
                                <p:inputText id="correo" validatorMessage="Correo no valido" value="#{registro.email}">

                                    <p:clientValidator event="blur"/>
                                    <p:tooltip for="correo" value="Ingresa el Correo"/>
                                    <p:watermark for="correo" value="[email protected]"/>
                                    <p:message for="correo" style="color: red"/>
                                </p:inputText>
                            </p:outputLabel>
                        </h:panelGrid>
                        <br/>
                        <p:commandButton value="Guardar" action="#{registro.registrar()}"/>

                    </div>
                    <!--<div class="g-recaptcha" data-sitekey="6LcOITgUAAAAAKVljosN9opvihgMsQ_ZvzMzT_rK"></div>-->
                </h:form>
            </ui:define>
            <ui:define name="footer"/>
        </ui:composition>

    </h:body>
</f:view>

    
asked by zentx11 23.11.2017 в 08:03
source

0 answers