Package org.primefaces.model

Examples of org.primefaces.model.TreeNode


  protected void encodeScript(FacesContext facesContext, Tree tree) throws IOException {
    ResponseWriter writer = facesContext.getResponseWriter();
    String clientId = tree.getClientId(facesContext);
    String formClientId = null;
    String treeVar = createUniqueWidgetVar(facesContext, tree);
    TreeNode root = (TreeNode) tree.getValue();
   
    UIComponent parentForm = ComponentUtils.findParentForm(facesContext, tree);
    if(parentForm != null)
      formClientId = parentForm.getClientId(facesContext);
    else
      throw new FacesException("Tree:" + clientId + " needs to be enclosed in a form");
     
    writer.startElement("script", null);
    writer.writeAttribute("type", "text/javascript", null);

    //Nodes
    writer.write(treeVar + " = new PrimeFaces.widget.TreeView('" + clientId + "', [\n");
    if(root != null) {
      int rowIndex = 0;
      for(Iterator<TreeNode> iterator = root.getChildren().iterator(); iterator.hasNext();) {
        encodeTreeNode(facesContext, tree, iterator.next(), String.valueOf(rowIndex));
        rowIndex ++;
       
        if(iterator.hasNext())
          writer.write(",");
View Full Code Here

TOP

Related Classes of org.primefaces.model.TreeNode

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.