2012-07-03 70 views
0

我有一個豐富的樹,它包含幾個節點。每個節點旁邊都有一個複選框。當我檢查複選框時,需要檢查與所有孩子有關的複選框,並且當我取消選中所有孩子時,必須取消選中。我在我的xhtml中有下面的代碼。在輔助bean中,我根據事件將所有孩子設置爲選中/取消選中。樹最初處於「摺疊」模式。當我點擊複選框並展開節點時,我可以看到所有正在檢查的孩子。但是,當我取消選中/檢查擴展模式時,這些值不會反映在子元素中。你能幫我讓我知道我錯過了什麼嗎?謝謝。JSF豐富的樹+ AJAX

<rich:tree id="producttree" switchType="server" 
     value="#updateProductBean.deviceServiceTreeRoot}" var="item"> 
     <rich:treeNode id="productnode"> 
      <h:selectBooleanCheckbox value="#{item.selected}" 
       rendered="#{item.value == null &amp;&amp; item.checkbox == true}" 
       valueChangeListener="#{updateProductBean.submitUpdateProduct}"> 
       <f:attribute name="selectedProductId" id="selectedProductId" 
        value="#{item.paramID}" /> 
       <f:attribute name="selectedProductName" id="selectedProductName" 
        value="#{item.name}" /> 
       <a4j:support event="onclick" reRender="producttree,productnode"> 
       </a4j:support> 
      </h:selectBooleanCheckbox> 
      <h:outputText value="#{item.name}" rendered="#{item.value == null}" /> 
     </rich:treeNode> 
    </rich:tree> 
+0

我在猜測它的reRendering問題。你確定複選框被選中後樹會被重建嗎? –

+0

感謝您的迴應艾莉 - 我不確定樹是否正在完全重建。我添加了與複選框「selected」屬性有關的布爾變量作爲輸出文本。該值正在改變我正在檢查的複選框 - 但不確定是否重新呈現chold元素。 –

回答

3

嘗試包裝你的h:selectBooleanCheckBoxa4j:outputPanel標籤,然後在你的a4j:support標籤定義一個id的名字,然後重新呈現這個a4j:outputPanel。如果它仍然沒有reRendered嘗試將ajaxRendered="true"放在您的a4j:outputPanel這將使其始終更新爲每個ajax請求。

試試這個。

<rich:tree id="producttree" switchType="server" 
       value="#updateProductBean.deviceServiceTreeRoot}" var="item"> 
       <rich:treeNode id="productnode"> 
        <a4j:outputPanel id="panel" ajaxRendered="true"> 
         <h:selectBooleanCheckbox value="#{item.selected}" 
          rendered="#{item.value == null &amp;&amp; item.checkbox == true}" 
          valueChangeListener="#{updateProductBean.submitUpdateProduct}"> 
          <f:attribute name="selectedProductId" id="selectedProductId" 
           value="#{item.paramID}" /> 
          <f:attribute name="selectedProductName" id="selectedProductName" 
           value="#{item.name}" /> 
          <a4j:support event="onclick" 
           reRender="producttree,productnode, panel"> 
          </a4j:support> 
         </h:selectBooleanCheckbox> 
        </a4j:outputPanel> 
        <h:outputText value="#{item.name}" 
         rendered="#{item.value == null}" /> 
       </rich:treeNode> 
      </rich:tree> 
+0

謝謝Ellie!將嘗試並提供更新。 –

+0

嗨艾莉,試過這個,但是這並沒有更新與子元素有關的複選框:( –

+0

嘗試檢查節點內複選框的值是否更新,樹是否正確重建,因爲它在崩潰模式下工作。 –

-1

它渲染了整個一級到您的樹點擊所以,如果您有任何Ajax調用,然後它會調用非常第一節點和將跳過休息。整個故事正在映射整個層面。

+1

你可能會考慮改寫你的答案,爲清晰起見,舉一個例子來說明你的觀點 –

相關問題