primefaces: Tree: dynamic,selection attribute not working

Describe the defect Using Tree component with dynamic= true prevent to call the method specified via selection attribute

             <p:tree id="costTree" value="#{viewComplete.costRoot}" var="node" selectionMode="single"
                                        selection="#{viewComplete.costSelected}" dynamic="true" >
                        <p:ajax event="select" update=":form:costSelValore :form:costSelDescr :form:buttonCost" listener="#{viewComplete.onNodeSelect}" process="@this"/>
                        <p:treeNode expandedIcon="pi pi-folder-open" collapsedIcon="pi pi-folder">
                            <h:outputText value="#{node.value}"/>
                        </p:treeNode> 
                    </p:tree>

Then when I select a node in the tree , the method below will be run but with NULL as argument

public void setCostSelected(TreeNode costSelected) {
        this.costSelected = costSelected;
    }

Environment:

  • PF Version: _10.0.6
  • JSF + version: _e.g. Mojarra 3.0.0
  • Affected browsers: ALL_

To Reproduce Steps to reproduce the behavior:

  1. Create a simple tree with dynamic = true and a correct dynamic model.set attribute selection= bean.method (all as above reported). Create a method inside the bean (all as above reported) .
  2. Click on a node of tree
  3. whatch break point on method
  4. check the TreeNode argument inside method and see it is NULL

Expected behavior the argument on the method must be valrized as the node selected on the page

Example XHTML

<p:tree id="costTree" value="#{viewComplete.costRoot}" var="node" selectionMode="single"
                                        selection="#{viewComplete.costSelected}" dynamic="true" >
                        <p:ajax event="select" update=":form:costSelValore :form:costSelDescr :form:buttonCost" listener="#{viewComplete.onNodeSelect}" process="@this"/>
                        <p:treeNode expandedIcon="pi pi-folder-open" collapsedIcon="pi pi-folder">
                            <h:outputText value="#{node.value}"/>
                        </p:treeNode> 
                    </p:tree>`

Example Bean

public void setCostSelected(TreeNode costSelected) {
        this.costSelected = costSelected;
    }

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 16 (9 by maintainers)

Most upvoted comments

appendTo=“@(body)” will move it to a place, where you have NO outer form probably, which is a user error actually

@FlipWarthog any interest in investigating?