a4j:reRender中的支持无效

时间:2014-09-02 09:59:44

标签: jsf richfaces jsf-1.2 ajax4jsf

我有一个按钮。如果按此按钮,则应显示一个复选框 这当然很有效。复选框应该在更改时调用一个函数,该函数应该只是System.out.println(),所以我看到它被调用。
问题是:只是简单的复选框功能,没有重新渲染工作很好。但是一旦a4j:support被重新渲染,它就无法正常工作,System.out.println()永远不会被调用

这看起来很简单,但我不知道为什么它根本不起作用!
任何提示/技巧?

这是旧环境,所以只有JSF 1.2。

我的xhtml                                   

        <s:div id="sdBoolCheckboxtest">
        #{testController.testRerenderBool}
            <s:div id="sdRerender" rendered="#{testController.testRerenderBool}">
                <h:selectBooleanCheckbox id="myscheckbox" value="#{testController.testBool}">
                    <a4j:support ajaxSingle="true" event="onclick" immediate="true"
                        status="globalStatus" action="#{testController.testCheckbox()}" />
                </h:selectBooleanCheckbox>
            </s:div>
        </s:div>
    </h:form>

我的Java课程:

@Name("testController")
@AutoCreate
public class TestController {

    private boolean testBool = false;

    public boolean isTestRerenderBool() {
        return testRerenderBool;
    }

    public void setTestRerenderBool(boolean testRerenderBool) {
        this.testRerenderBool = testRerenderBool;
    }

    private boolean testRerenderBool;

    public void switchtestRerenderBool(){
        System.out.println("switch");
        testRerenderBool = !testRerenderBool;       
    }

    public void testCheckbox(){
        System.out.println("drin");
    }

    public boolean isTestBool() {
        return testBool;
    }

    public void setTestBool(boolean testBool) {
        this.testBool = testBool;
    }
}

1 个答案:

答案 0 :(得分:0)

好的,我通过这些改变让它发挥作用:

首先我将@Scope(ScopeType.CONVERSATION)添加到TestController

@Name("testController")
@AutoCreate
@Scope(ScopeType.CONVERSATION)
public class TestController {
...
}

作为第二个更改,我将<s:div更改为<a4j:outputPanel

<a4j:outputPanel id="sdBoolCheckboxtest">

这解决了我的问题,但我仍然想知道为什么我需要@Scope(ScopeType.CONVERSATION)(我发现了a4j的提示:outputPanel here

任何解释都会有所帮助,谢谢!

相关问题