0

Richfaces で JSON を使用する方法に関する例を見つけましたが、機能していません...何か不足しているかどうかわかりません..ここにコードがあります:

<h:form id="form1" prependId="false">

    <a4j:jsFunction 
        name="submitApplication"
        action="#{jsFunctionBean.actionMethod}"
        data="#{jsFunctionBean}"
        oncomplete="processData(event.data)" 
        immediate="true">
    </a4j:jsFunction>

    <script type="text/javascript">
        //example callback function with JSON data as argument
        function processData(data) {
            alert(data.test);
            alert(data.name);
        }

        //call the ajax method from javascript
        submitApplication();
    </script>

</h:form>

そして豆:

@ManagedBean(name = "jsFunctionBean") @SessionScoped

public class JsFunctionBean {

    /**
     * Test String name
     */
    private String name;

    public String getName() { return this.name; }
    public void setName(String name) { this.name = name; }

    /**
     * Test boolean
     */
    private boolean test;
    public boolean getTest() { return this.test; }
    public void setTest(boolean test) { this.test = test; }    

    /**
     * Action Method 
     * 
     * @return
     */
    public String getActionMethod() {
        this.test = true;
        this.name = "Dave";
        return null;
    }


}

このコードを実行すると、アラートが表示されず、ブラウザーに「'data' が null またはオブジェクトではありません」というエラーが表示されます。私はjsf 1.2とrichfaces 3.3.3を使用しています。

何か案が?

よろしくお願いします。

4

0 に答える 0