Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 将参数传递给函数JSF_Java_Hibernate_Jsf - Fatal编程技术网

Java 将参数传递给函数JSF

Java 将参数传递给函数JSF,java,hibernate,jsf,Java,Hibernate,Jsf,大家好,我需要向actionListener传递一些参数这是我的代码 <p:dialog id="dialog" header="Acceso Restringido" widgetVar="dlgRegister" modal="true"> <h:form> <h:panelGrid columns="2" cellpadding="5"> <h:outputLabel for="username" value=

大家好,我需要向actionListener传递一些参数这是我的代码

<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>  

我需要将svalue=“#{loginBean.usuario.username}”示例传递给actionListener=“#{loginBean.login(actionEvent,---HERE--)}”

  • 该值已在loginBean.usario.username中设置
  • 您可以像loginBean.usario.username一样在那里进行设置
  • 这是不对的。范围中根本不存在托管bean
    {actionEvent}
    。JSF已经为action listener方法准备了真正的
    ActionEvent
    参数本身。省略一下:

    actionListener="#{loginBean.login}"  
    
    JSF将隐式地创建并传递正确的参数

    您可以直接在方法内部访问用户名:

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