Ejemplo n.º 1
0
  private void printNameString(
      JspWriter out,
      TreeControlNode node,
      boolean isCatalog,
      String updateTreeAction,
      HttpServletResponse response,
      String hyperlink,
      String action)
      throws IOException {
    // if ((action != null) && (isCatalog || !node.isLeaf()))
    if (action != null) {
      out.print("<a href=\"");
      out.print(response.encodeURL(action));
      out.print("\"");
      out.print(" onclick=\"");
      out.print("self.location.href='" + updateTreeAction + "'");
      out.print("\">");
      out.print("<img src=\"");

      if (node.isExpanded()) {
        out.print(IMAGE_HANDLE_EXPANDED);
      } else {
        out.print(IMAGE_HANDLE_UNEXPANDED);
      }

      out.print("\" border=\"0\">");
      out.print("</a>");

      // Render the label for this node (if any)
      if (node.getLabel() != null) {
        if (hyperlink != null) {
          // Note the leading space so that the text has some space
          // between it and any preceding images
          out.print("<a href=\"");
          out.print(hyperlink);
          out.print("\"");

          String target = node.getTarget();

          if (target != null) {
            out.print(" target=\"");
            out.print(target);
            out.print("\"");
          }

          // to refresh the tree in the same 'self' frame
          out.print(" onclick=\"");
          out.print("self.location.href='" + updateTreeAction + "'");
          out.print("\"");
          out.print(">");
        }

        if (node.isSelected()) {
          out.println("<B>");
        }

        out.print(node.getLabel());

        if (node.isSelected()) {
          out.println("</B>");
        }

        if (hyperlink != null) {
          out.print("</a>");
        }
      }
    }
  }
Ejemplo n.º 2
0
  protected void render(JspWriter out, TreeControlNode node, int level, int width, boolean last)
      throws IOException {
    HttpServletResponse response = (HttpServletResponse) pageContext.getResponse();

    // if the node is root node and the label value is
    // null, then do not render root node in the tree.
    if ("ROOT-NODE".equalsIgnoreCase(node.getName()) && (node.getLabel() == null)) {
      // Render the children of this node
      TreeControlNode[] children = node.findChildren();
      int lastIndex = children.length - 1;
      int newLevel = level + 1;

      for (int i = 0; i < children.length; i++) {
        render(out, children[i], newLevel, width, i == lastIndex);
      }

      return;
    }

    //  trStyle = (trStyle.equals(StyleConstants.TR_STYLE2) ? StyleConstants.TR_STYLE1 :
    // StyleConstants.TR_STYLE2);

    // Render the beginning of this node
    // out.println(intervalTR);
    trStyle =
        (trStyle.equals(StyleConstants.TR_STYLE2)
            ? StyleConstants.TR_STYLE1
            : StyleConstants.TR_STYLE2);
    out.println("<tr class=" + trStyle + ">");
    out.println("<td align='left'>");

    // Create the appropriate number of indents
    for (int i = 0; i < (level - 1); i++) {
      out.print("&nbsp;&nbsp;&nbsp;");
    }

    // Render the tree state image for this node
    // HACK to take into account special characters like = and &
    // in the node name, could remove this code if encode URL
    // and later request.getParameter() could deal with = and &
    // character in parameter values.
    String encodedNodeName = URLEncoder.encode(node.getName());
    String action = replace(getAction(), "${name}", encodedNodeName);

    String updateTreeAction = replace(getAction(), "tree=${name}", "select=" + encodedNodeName);

    updateTreeAction =
        ((HttpServletResponse) pageContext.getResponse()).encodeURL(updateTreeAction);

    String[] tempArray = null;
    String nameTempString = node.getName();
    boolean isCatalog = false;

    // create node's image
    String hyperlink = null;
    OrganForm of = null;

    if (nameTempString.indexOf("/") > 0) {
      tempArray = StringUtil.splitString(nameTempString, "/");

      if (tempArray != null) {
        String organ0ID = tempArray[1];
        of = OrganHelper.getOrgan(Integer.parseInt(organ0ID));
      }

      if (para1.equals("-1")) {
        out.print("<input type=\"radio\"");
      } else {
        out.print("<input type=\"checkbox\"");
      }

      out.println(" name=\"orgID\" value=\"" + tempArray[1] + "\">");
    }

    printNameString(out, node, isCatalog, updateTreeAction, response, hyperlink, action);

    out.println("</td>");

    String orgNo = "";
    int total = 0;

    if (tempArray != null) {
      String organ0ID = tempArray[1];

      if (!para1.equals("-1")) {
        int colSignDetailID = Integer.parseInt(para1);
        total =
            ColStudentHelper.getStudentNumber(
                Integer.parseInt(organ0ID),
                colSignDetailID,
                SecurityConstants.USER_DEFAULT_RELATION);
      } else {
        total = ColSignHelper.totalNumInOrg(Integer.parseInt(organ0ID), 1);
      }

      of = OrganHelper.getOrgan(Integer.parseInt(organ0ID));

      if (of != null) {
        orgNo = of.getOrgNO();
      }
    }

    out.println("<td  align=\"center\">");
    out.println("&nbsp;" + orgNo);
    out.println("</td>");
    out.println("<td align=\"center\">");
    out.println("&nbsp;" + total);
    out.println("</td>");
    // Render the end of this node
    out.println("</tr>");

    // Render the children of this node
    if (node.isExpanded()) {
      TreeControlNode[] children = node.findChildren();
      int lastIndex = children.length - 1;
      int newLevel = level + 1;

      for (int i = 0; i < children.length; i++) {
        render(out, children[i], newLevel, width, i == lastIndex);
      }
    }
  }