2014-09-02 43 views
0

我有一個按鈕。如果這被按下,應該呈現一個複選框。
這當然工作得很好。該複選框應該,當改變時調用一個函數,這應該只是System.out.println()東西,所以我看到它的調用。
問題是:只是簡單的複選框功能,沒有渲染效果很好。但一旦a4j:support重新顯示,它不工作,System.out.println()永遠不會被稱爲a4j:在reRender中的支持不起作用

這看起來很容易,但我不知道它爲什麼不工作!
任何暗示/詭計?

這是舊的環境,所以只有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; 
    } 
} 

回答

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

任何解釋會有幫助,謝謝!