0

Hi guys i need to pass some parameters to an actionListener this is my code

<p:dialog id="dialog" header="Acceso Restringido" widgetVar="dlgRegister" modal="true">  
<h:form>  

    <h:panelGrid columns="2" cellpadding="5">  
        <h:outputLabel for="username" value="Nombre de Usuario:" />  
        <p:inputText value="#{loginBean.usuario.username}"   
                id="username" required="true" label="username" />  

        <h:outputLabel for="password" value="ContraseƱa:" />  
        <h:inputSecret value="#{loginBean.usuario.password}"   
                id="password" required="true" label="password" />

        <h:outputLabel for="correo" value="Correo:" />  
        <h:inputSecret value="#{loginBean.usuario.correo}"   
                id="correo" required="true" label="correo" />

        <f:facet name="footer">  
            <p:commandButton id="regButton" value="Registrar" update=":growl"   
                             actionListener="#{loginBean.login(actionEvent)}"   
                oncomplete="handleLoginRequest(xhr, status, args)"/>  
        </f:facet>  
    </h:panelGrid>  

</h:form>  

well I need to pas svalue="#{loginBean.usuario.username}" example to actionListener="#{loginBean.login(actionEvent,---HERE----)}"

Daniel Sibaja
  • 1,247
  • 3
  • 12
  • 15

2 Answers2

1
actionListener="#{loginBean.login(actionEvent)}"  

This is not right. There does not exist a managed bean #{actionEvent} in the scope at all. JSF will already prepare the real ActionEvent argument itself for action listener methods. Just omit it:

actionListener="#{loginBean.login}"  

JSF will implicitly create and pass the right argument.

You can access the username just straight inside the method:

public void login(ActionEvent event) {
    System.out.println(usario.getUsername()); // Look, it's already been set by JSF.
}

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555
0
  1. The value is setted in loginBean.usario.username already
  2. You can set that there just like loginBean.usario.username
Alex
  • 2,126
  • 3
  • 25
  • 47