a4j:单击按钮后不调用jsFunction

时间:2013-03-06 16:54:16

标签: richfaces ajax4jsf

我正在开发我的jsf2,jaas,richfaces应用程序,我有这个登录页面

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:h="http://java.sun.com/jsf/html"
    xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich" template = "/WEB-INF/template/login.xhtml" >

        <p>Login to access secure pages:</p>
        <form method='post' action='j_security_check'>
            <h:messages layout='table' errorStyle='background: #AFEEEE;'
                infoStyle='background: #AFEEEE;' globalOnly='true' />
            <h:panelGrid columns='2' styleClass="myTable3">
                <h:outputLabel value='Username: ' />
                <input type='text' id='j_username' name='j_username' />
                <h:outputLabel value='Password: ' />
                <input type='password' id='j_password' name='j_password' />
                <h:outputText value='' />
                <h:panelGrid columns='1'>
                    <input type='submit' name='submit' value='Login' onclick="selectActiveClient();"/>
                </h:panelGrid>
            </h:panelGrid>
        </form>


            <a4j:jsFunction name="selectActiveClient"
                action="#{selectBean.someAction()}"
                render="pannelloClientiAttivi"/>

</ui:composition>

但是没有调用selectActiveClient,出了什么问题?

2 个答案:

答案 0 :(得分:0)

a4j:jsFunction需要一个表单,请按h:form包装。

答案 1 :(得分:0)

使用<h:commandButton>代替<input type='submit' name='submit' value='Login' onclick="selectActiveClient();"/>