Package org.apache.myfaces.tobago.component

Examples of org.apache.myfaces.tobago.component.UITreeOldNode


      UIComponent component) throws IOException {

    UITreeOld tree = (UITreeOld) component;

    String clientId = tree.getClientId(facesContext);
    UITreeOldNode root = tree.getRoot();
    TreeState state = tree.getState();

    TobagoResponseWriter writer = HtmlRendererUtil.getTobagoResponseWriter(facesContext);
    writer.startElement(HtmlConstants.DIV, tree);
    writer.writeNameAttribute(clientId + UITreeOld.TREE_DIV);
View Full Code Here


  public void decode(FacesContext facesContext, UIComponent component) {
    if (ComponentUtil.isOutputOnly(component)) {
      return;
    }

    UITreeOldNode node = (UITreeOldNode) component;
    UITreeOld tree = node.findTreeRoot();
    TreeState state = tree.getState();
    String treeId = tree.getClientId(facesContext);
    String nodeId = node.getId();
    final Map requestParameterMap
        = facesContext.getExternalContext().getRequestParameterMap();

    // expand state
    String expandState = (String) requestParameterMap.get(treeId);
    String searchString = ";" + nodeId + ";";
    if (expandState.indexOf(searchString) > -1) {
      state.addExpandState((DefaultMutableTreeNode) node.getValue());
    }


    if (TreeOldRenderer.isSelectable(tree)) { // selection
      String selected = (String) requestParameterMap.get(treeId + UITreeOld.SELECT_STATE);
      searchString = ";" + nodeId + ";";
      if (selected.indexOf(searchString) > -1) {
        state.addSelection((DefaultMutableTreeNode) node.getValue());
      }
    }

    // marker
    String marked = (String) requestParameterMap.get(treeId + UITreeOld.MARKER);
    if (marked != null) {
      searchString = treeId + NamingContainer.SEPARATOR_CHAR + nodeId;

      if (marked.equals(searchString)) {
        state.setMarker((DefaultMutableTreeNode) node.getValue());
      }
    }


    // link
    // FIXME: this is equal to the CommandRendererBase, why not use that code?
    String actionId = ComponentUtil.findPage(component).getActionId();
    if (LOG.isDebugEnabled()) {
      LOG.debug("actionId = '" + actionId + "'");
      LOG.debug("nodeId = '" + treeId + NamingContainer.SEPARATOR_CHAR
          + nodeId + "'");
    }
    if (actionId != null
        && actionId.equals(treeId + NamingContainer.SEPARATOR_CHAR + nodeId)) {
      UICommand treeNodeCommand
          = (UICommand) tree.getFacet(UITreeOld.FACET_TREE_NODE_COMMAND);
      if (treeNodeCommand != null) {
        UIParameter parameter = ensureTreeNodeParameter(treeNodeCommand);
        parameter.setValue(node.getId());
//        LOG.error("no longer supported: treeNodeCommand.fireActionEvent(facesContext));");
//        treeNodeCommand.fireActionEvent(facesContext); // FIXME jsfbeta
//        component.queueEvent(new ActionEvent(component));
        treeNodeCommand.queueEvent(new ActionEvent(treeNodeCommand));
      }

      UIForm form = ComponentUtil.findForm(component);
      if (form != null) {
        form.setSubmitted(true);
        if (LOG.isDebugEnabled()) {
          LOG.debug("setting Form Active: " + form.getClientId(facesContext));
        }
      }

      if (LOG.isDebugEnabled()) {
        LOG.debug("actionId: " + actionId);
        LOG.debug("nodeId: " + nodeId);
      }
    }

    node.setValid(true);
  }
View Full Code Here

  }

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

    UITreeOldNode treeNode = (UITreeOldNode) component;

    String clientId = treeNode.getClientId(facesContext);
    UIComponent parent = treeNode.getParent();

    String parentClientId = null;
    if (parent != null && parent instanceof UITreeOldNode) { // if not the root node
      parentClientId = treeNode.getParent().getClientId(facesContext);
    }

    UITreeOld root = treeNode.findTreeRoot();
    String rootId = root.getClientId(facesContext);

    String jsClientId = TreeOldRenderer.createJavascriptVariable(clientId);
    String jsParentClientId = TreeOldRenderer.createJavascriptVariable(
        parentClientId);
//  rootId = HtmlUtils.createJavascriptVariable(rootId);

    TreeState treeState = root.getState();
    if (treeState == null) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("No treeState found. clientId=" + clientId);
      }
    } else {

      DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeNode.getValue();

      ResponseWriter writer = facesContext.getResponseWriter();

      String debuging = null;

      writer.writeText("  var ", null);
      writer.writeText(jsClientId, null);
      writer.writeText(" = new TreeNode('", null);
      // label
      Object name = treeNode.getAttributes().get(TobagoConstants.ATTR_NAME);
      if (LOG.isDebugEnabled()) {
        debuging += name + " : ";
      }
      if (name != null) {
        writer.writeText(StringEscapeUtils.escapeJavaScript(name.toString()), null);
      } else {
        LOG.warn("name = null");
      }
      writer.writeText("',", null);

      // tip
      Object tip = treeNode.getAttributes().get(TobagoConstants.ATTR_TIP);
      if (tip != null) {
        tip = StringEscapeUtils.escapeJavaScript(tip.toString());
        writer.writeText("'", null);
        writer.writeText((String) tip, null);
        writer.writeText("','", null);
View Full Code Here


    List nodes = ((UITreeListboxBox) component).getNodes();

    for (int i = 0; i < nodes.size(); i++) {
      UITreeOldNode treeNode = (UITreeOldNode) nodes.get(i);
      DefaultMutableTreeNode node = treeNode.getTreeNode();

      writer.startElement(HtmlConstants.OPTION, treeNode);
//      writer.writeAttribute(HtmlAttributes.ONCLICK, "tbgTreeListboxClick(this, '" + treeId + "')", null);
      writer.writeAttribute(HtmlAttributes.VALUE, Integer.toString(i), null);
      if (treeNode.equals(tree.getSelectedNode(level))
          || tree.isSelectedNode(node)) {
        writer.writeAttribute(HtmlAttributes.SELECTED, true);
      }
      writer.writeAttribute(HtmlAttributes.TITLE, null, ATTR_TIP);
      writer.writeText(treeNode.getAttributes().get(ATTR_NAME), null);
      if (node.getChildCount() > 0) {
        writer.writeText(" \u2192", null);
      }
      writer.endElement(HtmlConstants.OPTION);
    }
View Full Code Here

    UITreeListbox tree = (UITreeListbox) component;
    tree.createSelectionPath();

    String clientId = tree.getClientId(facesContext);
    UITreeOldNode root = tree.getRoot();


    UIPage page = ComponentUtil.findPage(tree);
    if (LOG.isDebugEnabled()) {
      page.getOnloadScripts().add("tbgTreeStates('" + clientId + "')");
View Full Code Here

      UIComponent component) throws IOException {

    UITreeOld tree = (UITreeOld) component;

    String clientId = tree.getClientId(facesContext);
    UITreeOldNode root = tree.getRoot();

    TobagoResponseWriter writer = (TobagoResponseWriter) facesContext.getResponseWriter();

    writer.startElement(HtmlConstants.DIV, tree);
    writer.writeComponentClass();
View Full Code Here

  public void decode(FacesContext facesContext, UIComponent component) {
    if (ComponentUtil.isOutputOnly(component)) {
      return;
    }

    UITreeOldNode node = (UITreeOldNode) component;
    UITreeOld tree = node.findTreeRoot();
    TreeState state = tree.getState();
    String treeId = tree.getClientId(facesContext);
    String nodeId = node.getId();
    final Map requestParameterMap
        = facesContext.getExternalContext().getRequestParameterMap();

    // expand state
    String expandState = (String) requestParameterMap.get(treeId);
    String searchString = ";" + nodeId + ";";
    if (StringUtils.contains(expandState, searchString)) {
      state.addExpandState((DefaultMutableTreeNode) node.getValue());
    }


    if (TreeOldRenderer.isSelectable(tree)) { // selection
      String selected = (String) requestParameterMap.get(treeId + UITreeOld.SELECT_STATE);
      searchString = ";" + nodeId + ";";
      if (StringUtils.contains(selected, searchString)) {
        state.addSelection((DefaultMutableTreeNode) node.getValue());
      }
    }

    // marker
    String marked = (String) requestParameterMap.get(treeId + UITreeOld.MARKER);
    if (marked != null) {
      searchString = treeId + NamingContainer.SEPARATOR_CHAR + nodeId;

      if (marked.equals(searchString)) {
        state.setMarker((DefaultMutableTreeNode) node.getValue());
      }
    }


    // link
    // FIXME: this is equal to the CommandRendererBase, why not use that code?
    String actionId = ComponentUtil.findPage(facesContext, component).getActionId();
    if (LOG.isDebugEnabled()) {
      LOG.debug("actionId = '" + actionId + "'");
      LOG.debug("nodeId = '" + treeId + NamingContainer.SEPARATOR_CHAR
          + nodeId + "'");
    }
    if (actionId != null
        && actionId.equals(treeId + NamingContainer.SEPARATOR_CHAR + nodeId)) {
      UICommand treeNodeCommand
          = (UICommand) tree.getFacet(UITreeOld.FACET_TREE_NODE_COMMAND);
      if (treeNodeCommand != null) {
        UIParameter parameter = ensureTreeNodeParameter(treeNodeCommand);
        parameter.setValue(node.getId());
//        LOG.error("no longer supported: treeNodeCommand.fireActionEvent(facesContext));");
//        treeNodeCommand.fireActionEvent(facesContext); // FIXME jsfbeta
//        component.queueEvent(new ActionEvent(component));
        treeNodeCommand.queueEvent(new ActionEvent(treeNodeCommand));
      }

      UIForm form = ComponentUtil.findForm(component);
      if (form != null) {
        form.setSubmitted(true);
        if (LOG.isDebugEnabled()) {
          LOG.debug("setting Form Active: " + form.getClientId(facesContext));
        }
      }

      if (LOG.isDebugEnabled()) {
        LOG.debug("actionId: " + actionId);
        LOG.debug("nodeId: " + nodeId);
      }
    }

    node.setValid(true);
  }
View Full Code Here

  }

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

    UITreeOldNode treeNode = (UITreeOldNode) component;

    String clientId = treeNode.getClientId(facesContext);
    UIComponent parent = treeNode.getParent();

    String parentClientId = null;
    if (parent != null && parent instanceof UITreeOldNode) { // if not the root node
      parentClientId = treeNode.getParent().getClientId(facesContext);
    }

    UITreeOld root = treeNode.findTreeRoot();
    String rootId = root.getClientId(facesContext);

    String jsClientId = TreeOldRenderer.createJavascriptVariable(clientId);
    String jsParentClientId = TreeOldRenderer.createJavascriptVariable(
        parentClientId);
//  rootId = HtmlUtils.createJavascriptVariable(rootId);

    TreeState treeState = root.getState();
    if (treeState == null) {
      if (LOG.isDebugEnabled()) {
        LOG.debug("No treeState found. clientId=" + clientId);
      }
    } else {

      DefaultMutableTreeNode node = (DefaultMutableTreeNode) treeNode.getValue();

      ResponseWriter writer = facesContext.getResponseWriter();

      String debuging = null;

      writer.writeText("  var ", null);
      writer.writeText(jsClientId, null);
      writer.writeText(" = new TreeOldNode('", null);
      // label
      Object name = treeNode.getAttributes().get(TobagoConstants.ATTR_NAME);
      if (LOG.isDebugEnabled()) {
        debuging += name + " : ";
      }
      if (name != null) {
        writer.writeText(StringEscapeUtils.escapeJavaScript(name.toString()), null);
      } else {
        LOG.warn("name = null");
      }
      writer.writeText("',", null);

      // tip
      Object tip = treeNode.getAttributes().get(TobagoConstants.ATTR_TIP);
      if (tip != null) {
        tip = StringEscapeUtils.escapeJavaScript(tip.toString());
        writer.writeText("'", null);
        writer.writeText((String) tip, null);
        writer.writeText("','", null);
View Full Code Here

    UITreeListbox tree = (UITreeListbox) component;
    tree.createSelectionPath();

    String clientId = tree.getClientId(facesContext);
    UITreeOldNode root = tree.getRoot();


    UIPage page = ComponentUtil.findPage(facesContext, tree);
    if (LOG.isDebugEnabled()) {
      page.getOnloadScripts().add("tbgTreeStates('" + clientId + "')");
View Full Code Here


    List nodes = ((UITreeListboxBox) component).getNodes();

    for (int i = 0; i < nodes.size(); i++) {
      UITreeOldNode treeNode = (UITreeOldNode) nodes.get(i);
      DefaultMutableTreeNode node = treeNode.getTreeNode();

      writer.startElement(HtmlConstants.OPTION, treeNode);
//      writer.writeAttribute(HtmlAttributes.ONCLICK, "tbgTreeListboxClick(this, '" + treeId + "')", null);
      writer.writeAttribute(HtmlAttributes.VALUE, i);
      if (treeNode.equals(tree.getSelectedNode(level))
          || tree.isSelectedNode(node)) {
        writer.writeAttribute(HtmlAttributes.SELECTED, true);
      }
      HtmlRendererUtil.renderTip(treeNode, writer);
      writer.writeText(treeNode.getAttributes().get(ATTR_NAME), null);
      if (node.getChildCount() > 0) {
        writer.writeText(" \u2192");
      }
      writer.endElement(HtmlConstants.OPTION);
    }
View Full Code Here

TOP

Related Classes of org.apache.myfaces.tobago.component.UITreeOldNode

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.