【问题标题】:a4j:support in a reRender is not workinga4j:重新渲染中的支持不起作用
【发布时间】:2014-09-02 09:59:44
【问题描述】:

我有一个按钮。如果按下此按钮,则应呈现一个复选框。
这当然工作得很好。该复选框应该在更改时调用一个函数,该函数应该只是 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;
    }
}

【问题讨论】:

    标签: jsf richfaces jsf-1.2 ajax4jsf


    【解决方案1】:

    好的,我得到了它的工作,有这些变化:

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

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

    作为第二个更改,我将 &lt;s:div 更改为 &lt;a4j:outputPanel

    <a4j:outputPanel id="sdBoolCheckboxtest">
    

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

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

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-10-08
      • 2013-07-18
      • 1970-01-01
      • 2012-06-05
      • 2011-07-27
      • 2013-09-22
      相关资源
      最近更新 更多