0

私は JSF と RichFaces の初心者です。RichFaces 4.X と JSF 2.0 を使用しています。コマンド ボタンが a4j ボタンと呼ばれるサンプル ページを作成しましたが、機能していないようです。これが私のページです。誰か助けてくれませんか

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml"
    xmlns:ui="http://java.sun.com/jsf/facelets"
    xmlns:h="http://java.sun.com/jsf/html"
    xmlns:a4j="http://richfaces.org/a4j"
    xmlns:rich="http://richfaces.org/rich"
    xmlns:f="http://java.sun.com/jsf/core">

<h:head>
    <title>My Registration Page</title>
    <link href="stylesheet/reset.css" rel="stylesheet" type="text/css" />
    <link href="stylesheet/style.css" rel="stylesheet" type="text/css" />
    <link rel="icon" type="image/png" href="images/icons/favicon.png" />

    <script language="javascript">
        function showProgressBar()
        {
            alert("its in show");
        }

        function hideProgressBar()
        {
            alert("its in hide");
        }
        </script>
</h:head>
<h:body>
    <a4j:jsFunction name="login" action="#{loginBean.validateUser}"
        onbegin="showProgressBar();"
        oncomplete="hideProgressBar();" />


    <div id="login-container">
        <div class="login-logo">
            <img src="images/logo.png" />
        </div>
        <f:view>
            <div id="loin-form">
                <h1>
                    Log in to your account or <a href="#">sign up</a> to Get Started
                </h1>
                <h:form>
                    <h:inputText id="userName" value="#{loginBean.userName}"
                        validator="#{loginBeanValidator.validateUserName}" required="true"
                        class="txtFld" />
                    <h:message for="userName"></h:message>
                    <h:inputSecret id="passWord" value="#{loginBean.passWord}"
                        validator="#{loginBeanValidator.validatePassword}" required="true"
                        class="pswrdFld" />
                    <h:message for="passWord"></h:message>
                    <p>
                        <a4j:commandLink id="forgotPasswordLink"
                            value="Forgot Your Password? " />
                        <a4j:commandButton id="loginButton" value="Sign In" action="login();"
                            styleClass="sign-btn" />
                    </p>
                </h:form>
            </div>
        </f:view>
    </div>
</h:body>
</html>
4

1 に答える 1

4

実際の問題はコマンドボタンにあります

 <a4j:commandButton id="loginButton" value="Sign In" action="login();"
     styleClass="sign-btn" />

「action」属性には、ボタンが押されたときにサーバー上で実行されるアクション メソッドまたはナビゲーション ルールに対する EL 式が必要です。a4j:jsFunction の目的は、javascript 呼び出しから ajax 要求を実行することであり、a4j:commandButton の目的は、押されたときに ajax 要求を実行することです。あなたの場合、実際には a4j:jsFunction は必要ありません。それを削除して、次のように a4j:commandButton に属性を配置します。

 <a4j:commandButton id="loginButton" value="Sign In" 
    action="#{loginBean.validateUser}" onbegin="showProgressBar();"
    oncomplete="hideProgressBar();" styleClass="sign-btn" />
于 2012-10-21T10:24:43.243 に答える