Package org.primefaces.model

Examples of org.primefaces.model.TreeNode


        Map<String,String> params = context.getExternalContext().getRequestParameterMap();
       
        String nodeKey = params.get(clientId + "_expand");
        if(nodeKey != null) {
            tt.setRowKey(nodeKey);
            TreeNode node = tt.getRowNode();
            node.setExpanded(true);
           
            encodeNodeChildren(context, tt, node);
        }
        else if(tt.isSortRequest(context)) {
            encodeSort(context, tt);
View Full Code Here


  protected void encodeMarkup(FacesContext context, TreeTable tt) throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    String clientId = tt.getClientId(context);
        boolean scrollable = tt.isScrollable();
        TreeNode root = tt.getValue();
       
        if(root.getRowKey() == null) {
            root.setRowKey("root");
            tt.buildRowKeys(root);
            tt.initPreselection();
        }
       
        //default sort
View Full Code Here

    writer.endElement("thead");
  }
      
    protected void encodeTbody(FacesContext context, TreeTable tt, boolean dataOnly) throws IOException {
    ResponseWriter writer = context.getResponseWriter();
    TreeNode root = (TreeNode) tt.getValue();
        String clientId = tt.getClientId(context);
    boolean empty = (root == null || root.getChildCount() == 0);
        UIComponent emptyFacet = tt.getFacet("emptyMessage");
       
        if(!dataOnly) {
            writer.startElement("tbody", null);
            writer.writeAttribute("id", clientId + "_data", null);
View Full Code Here

               
        encodeTbody(context, tt, true);
    }
   
    public void sort(TreeTable tt) {
        TreeNode root = tt.getValue();
        if(root == null)
            return;
       
        ValueExpression sortByVE = tt.getValueExpression("sortBy");
        SortOrder sortOrder = SortOrder.valueOf(tt.getSortOrder().toUpperCase(Locale.ENGLISH));
View Full Code Here

        }
       
        if(tree.isCheckboxSelection() && tree.isDynamic() && tree.isSelectionRequest(context)) {
            String selectedNodeRowKey = params.get(clientId + "_instantSelection");
            tree.setRowKey(selectedNodeRowKey);
            TreeNode selectedNode = tree.getRowNode();
            List<String> descendantRowKeys = new ArrayList<String>();
            tree.populateRowKeys(selectedNode, descendantRowKeys);
            int size = descendantRowKeys.size();
            StringBuilder sb = SharedStringBuilder.get(context, SB_DECODE_SELECTION);
           
View Full Code Here

        String clientId = tree.getClientId(context);
        String dragNodeRowKey = params.get(clientId + "_dragNode");
        String dropNodeRowKey = params.get(clientId + "_dropNode");
        String dragSource = params.get(clientId + "_dragSource");
        int dndIndex = Integer.parseInt(params.get(clientId + "_dndIndex"));
        TreeNode dragNode;
        TreeNode dropNode;
       
        if(dragSource.equals(clientId)) {
            tree.setRowKey(dragNodeRowKey);
            dragNode = tree.getRowNode();
        }
        else {
            Tree otherTree = (Tree) tree.findComponent(":" + dragSource);
            otherTree.setRowKey(dragNodeRowKey);
            dragNode = otherTree.getRowNode();
        }
       
        if(isValueBlank(dropNodeRowKey)) {
            dropNode = tree.getValue();
        }
        else {
            tree.setRowKey(dropNodeRowKey);
            dropNode = tree.getRowNode();
        }
       
        tree.setDragNode(dragNode);
        tree.setDropNode(dropNode);
       
        if(dndIndex >= 0 && dndIndex < dropNode.getChildCount())
            dropNode.getChildren().add(dndIndex, dragNode);
        else
            dropNode.getChildren().add(dragNode);
    }
View Full Code Here

            if(!vertical && rowKey.equals("root")) {
                encodeHorizontalTreeNodeChildren(context, tree, tree.getValue(), tree.getClientId(context), null, tree.isDynamic(), tree.isCheckboxSelection());
            }
            else {
                tree.setRowKey(rowKey);
                TreeNode node = tree.getRowNode();
                node.setExpanded(true);
               
                if(vertical) {
                    encodeTreeNodeChildren(context, tree, node, clientId, tree.isDynamic(), tree.isCheckboxSelection(), tree.isDroppable());
                }
                else {
View Full Code Here

        wb.finish();
  }
 
  protected void encodeMarkup(FacesContext context, Tree tree) throws IOException {
    boolean vertical = tree.getOrientation().equals("vertical");
        TreeNode root = (TreeNode) tree.getValue();
       
        if(root != null && root.getRowKey() == null) {
            root.setRowKey("root");
            tree.buildRowKeys(root);
            tree.initPreselection();
        }
   
        if(vertical)
View Full Code Here

    String selectionParam = clientId + "_selection";
   
    if(params.containsKey(clientId) && params.containsKey(rowKeyParam) && params.containsKey(actionParam)) {
      String rowKey = params.get(rowKeyParam);
      String event = params.get(actionParam);
      TreeNode root = (TreeNode) tree.getValue();
      TreeNode currentNode = treeExplorer.findTreeNode(rowKey, new TreeModel(root));
     
      switch(TreeNodeEvent.valueOf(event)) {
        case SELECT:
          tree.queueEvent(new NodeSelectEvent(tree, currentNode));
        break;
       
        case EXPAND:
          currentNode.setExpanded(true);
          tree.queueEvent(new NodeExpandEvent(tree, currentNode));
        break;

        case COLLAPSE:
          currentNode.setExpanded(false);
          tree.queueEvent(new NodeCollapseEvent(tree, currentNode));
        break;
      }
    }
   
View Full Code Here

  public void encodePartially(FacesContext facesContext, UIComponent component) throws IOException {
    Tree tree = (Tree) component;
    ResponseWriter writer = facesContext.getResponseWriter();
    Map<String,String> params = facesContext.getExternalContext().getRequestParameterMap();
    String clientId = tree.getClientId(facesContext);
    TreeNode root = (TreeNode) tree.getValue();
   
    String rowKey = params.get(clientId + "_rowKey");
    TreeNode currentNode = treeExplorer.findTreeNode(rowKey, new TreeModel(root));
    int rowIndex = 0;
   
    ServletResponse response = (ServletResponse) facesContext.getExternalContext().getResponse();
    response.setContentType("text/xml");
   
    writer.write("<nodes>");
   
    for(Iterator<TreeNode> iterator = currentNode.getChildren().iterator(); iterator.hasNext();) {
      TreeNode child = iterator.next();
      UITreeNode uiTreeNode = tree.getUITreeNodeByType(child.getType());
     
      facesContext.getExternalContext().getRequestMap().put(tree.getVar(), child.getData());
      writer.write("<node>");
     
        writer.write("<content>");
        RendererUtils.startCDATA(facesContext);
        renderChildren(facesContext, uiTreeNode);
        RendererUtils.endCDATA(facesContext);
        writer.write("</content>");
       
        writer.write("<rowKey>" + rowKey + "." + rowIndex + "</rowKey>");
        writer.write("<isLeaf>" + child.isLeaf() + "</isLeaf>");
        if(uiTreeNode.getStyleClass() != null) {
          writer.write("<contentClass>" + uiTreeNode.getStyleClass() + "</contentClass>");
        }
      writer.write("</node>");
     
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.