Esempio n. 1
0
  /** This method creates the HtmlTreeControl component used by the tag. */
  public HtmlComponent createComponent() {
    BaseTagHelper helper = getHelper();

    // craete a tree controll and get the tree buffer
    HtmlTreeControl tree = new HtmlTreeControl(getName(), getTheme(), helper.getController());
    _treeBuffer = tree.getTreeBuffer();

    tree.setSystemImages(getExpandimage(), getContractimage(), getNullimage());
    tree.setTargetFrame(getTarget());

    // treemode valid values are
    // * LINK (clicking on a link in the tree will cause the browser to follow a link)
    // * SUBMIT (clicking a link will cause the page to be submitted before following a link).

    int treeMode = TreeBuffer.MODE_SUBMIT;
    String treeModeStr = getTreemode();
    if (treeModeStr != null) {
      if (treeModeStr.equalsIgnoreCase("SUBMIT")) {
        treeMode = TreeBuffer.MODE_SUBMIT;
      } else if (treeModeStr.equalsIgnoreCase("LINK")) {
        treeMode = TreeBuffer.MODE_LINK;
      }
    }
    _treeBuffer.setMode(treeMode);

    // showroot (optional) true or false value indicating whether or not to display the root of the
    // tree.
    _treeBuffer.setShowRoot(BaseTagHelper.stringToBoolean(getShowroot(), true));

    // selectmode valid values are
    // * NONE - (No items on the tree can be selected)
    // * ONE (One item on the tree can be selected)
    // * MANY (Many items on the tree can be selected)

    int selectMode = TreeBuffer.SELECT_NONE;
    String selectModeStr = getSelectmode();
    if (selectModeStr != null) {
      if (selectModeStr.equalsIgnoreCase("NONE")) {
        selectMode = TreeBuffer.SELECT_NONE;
      } else if (selectModeStr.equalsIgnoreCase("ONE")) {
        selectMode = TreeBuffer.SELECT_ONE;
      } else if (selectModeStr.equalsIgnoreCase("MANY")) {
        selectMode = TreeBuffer.SELECT_MANY;
      }
    }
    _treeBuffer.setSelectMode(selectMode);

    return tree;
  }
Esempio n. 2
0
  /** This method generates the html used by the tag. */
  public void generateComponentHTML(JspWriter p) throws IOException {
    try {

      HtmlTreeControl tree = (HtmlTreeControl) getHelper().getController().getComponent(getName());
      if (tree == null) return;

      tree.generateHTML(new PrintWriter(p), -1);

    } catch (IOException ioe) {
      MessageLog.writeErrorMessage("generateComponentHTML", ioe, this);
      throw ioe;

    } catch (Exception e) {
      MessageLog.writeErrorMessage("generateComponentHTML", e, this);
    }
  }