Punter Vicky
Punter Vicky

Reputation: 16982

JSF rich tree + AJAX

I have a rich tree and it contains few nodes. I have a checkbox beside each node. When I check a checkbox , checkbox pertaining to all the children needs to be checked and when I uncheck all the children have to be unchecked. I have the below code in my xhtml. In the backing bean , I set all the children to checked / unchecked based on the event. The tree is initially in "collapsed" mode. When I click on the checkbox and expand the node , I can see all the children being checked. But when I uncheck / check in expanded mode , the values aren't getting reflected in the child elements. Can you please help in letting me know what I am missing? Thanks.

    <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>

Upvotes: 0

Views: 2181

Answers (2)

Ellie Fabrero
Ellie Fabrero

Reputation: 811

Try wrapping your h:selectBooleanCheckBox inside a a4j:outputPanel tag then define an id name, then reRender this a4j:outputPanel on your a4j:support tag. If it is still not reRendered try putting ajaxRendered="true" on your a4j:outputPanel this will make it always updated for every ajax request.

Try this.

<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>

Upvotes: 3

Bhup
Bhup

Reputation: 1

It Render the whole one level to which you click on tree so for that if you are having any ajax call then it will call the very first node and will skip for rest. The whole story is mapping the whole level.

Upvotes: -1

Related Questions