TreeTable's selectedNode is null

Components, Ajax Framework, Utilities and More.
Post Reply
david.acuna
Posts: 1
Joined: 25 Sep 2017, 16:06

25 Sep 2017, 18:18

Hi, I'm using primefaces 6.0 and I'm trying to get the value of the selected row from a TreeTable.
The component gets the data correctly from database, but the selected row is never taken in my backing been, selectedNode is always null

This is my html:

Code: Select all

p:treeTable id="cCostos" value="#{cuentaContableController.root}" var="centroCostos" selectionMode="single" selection="#{cuentaContableController.selectedNode}" style="width:80%; height:200px" >
											        <f:facet name="header">
											           Costs
											        </f:facet>
											        <p:column headerText="Code">
											            <h:outputText value="#{centroCostos.nombreCuentaContable}" />
											        </p:column>	
													<p:column headerText="Value">
											            <h:outputText value="#{centroCostos.codigoMedioMagnetico}" />
											        </p:column>			        
</p:treeTable>
This is my controller:

Code: Select all

@Named("cuentaContableController")
@SessionScoped
public class CuentaContableController implements Serializable {
	 private TreeNode root;
    private TreeNode selectedNode;
    
    @PostConstruct
	public void init() {
    	root=crearCentroCostos();    
    }
    
    
    public TreeNode crearCentroCostos(){
    	
    	CuentaContable laRaiz = new CuentaContable();    	
    	TreeNode root = new DefaultTreeNode(laRaiz, null);		
    			
    	for(CuentaContable cuenta : this.getItems()){    		
    		TreeNode node = new DefaultTreeNode(cuenta,root);    	
    	}
    }
    
    /**
	 * @return the root
	 */
	public TreeNode getRoot() {
		return root;
	}

	/**
	 * @param root the root to set
	 */
	public void setRoot(TreeNode root) {
		this.root = root;
	}

	/**
	 * @return the selectedNode
	 */
	public TreeNode getSelectedNode() {
		return selectedNode;
	}

	/**
	 * @param selectedNode the selectedNode to set
	 */
	public void setSelectedNode(TreeNode selectedNode) {
		this.selectedNode = selectedNode;
	}       
    
}
Can anyone help me by indicating what is missing! Thank you!

Post Reply
  • Information
  • Who is online

    Users browsing this forum: Google [Bot] and 8 guests