Package org.xulfaces.component.tree

Examples of org.xulfaces.component.tree.TreeComponent


@RENDERER(kit = "XUL_RENDERKIT", family = "xul.component.family", type = "xul.renderer.TreeChildren")
public class TreeChildrenRenderer extends XULRenderer {

  public void encodeChildren(FacesContext facesContext, UIComponent component) throws IOException {

    TreeComponent treeComponent = (TreeComponent) component.getParent();   
    TreeChildrenComponent treeChildrenComponent = (TreeChildrenComponent) component;
    ResponseWriter responseWriter = facesContext.getResponseWriter();   
    TreeModel treeModel = treeComponent.getTreeModel();
    DefaultMutableTreeNode treeNode = (DefaultMutableTreeNode) treeModel.getRoot();
    if (treeNode != null) {
      String var = (String) component.getParent().getAttributes().get("var");
      if (var != null) {
        Map sessionMap = facesContext.getExternalContext().getSessionMap();
View Full Code Here


  @Override
  public void decode(FacesContext facesContext, UIComponent component) {

    super.decode(facesContext, component);
   
    TreeComponent treeComponent = (TreeComponent) component;
    treeComponent.setSelectionPath(null);

    if (isSubmitted(facesContext, component)) {

      Map paramMap = facesContext.getExternalContext().getRequestParameterMap();
      String clientId = component.getClientId(facesContext);
      if (paramMap.containsKey(clientId)) {
        String selection = (String) paramMap.get(clientId);
        if ((selection != null) && (selection.length() > 0)) {

          String selections[] = selection.split(" ");
          if (selections != null) {
            // Get multi selections
            TreePath[] selectionPaths = new TreePath[selections.length];
            for (int i = 0; i < selections.length; i++) {
             
              int tiIndex = selections[i].lastIndexOf("ti_");             
              if (tiIndex != -1) {
               
                String path[] = selections[i].substring(tiIndex+3).split("_");
                TreeNode selectedNodes[] = new TreeNode[path.length];
                TreeNode currentNode = (TreeNode) treeComponent.getTreeModel().getRoot();
                selectedNodes[0] = currentNode;

                for (int j = 0; j < path.length; j++) {                 
                  String number = path[j];
                  int index = Integer.parseInt(number);
                  if (index < currentNode.getChildCount()) {
                    selectedNodes[j] = currentNode.getChildAt(index);
                    currentNode = selectedNodes[j];
                  }
                }
                selectionPaths[i] = new TreePath(selectedNodes);
              }
            }
            treeComponent.setSelectionPath(selectionPaths);
          }

        }
      }
      Set<Entry> entries = paramMap.entrySet();
      for (Entry entry : entries) {
        String key = (String) entry.getKey();
        if (key.startsWith(clientId)) {
          treeComponent.getAttributes().put(key, entry.getValue());
        }
      }
    }
  }
View Full Code Here

TOP

Related Classes of org.xulfaces.component.tree.TreeComponent

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.