Exemple #1
0
  public String getScript() {
    StringBuffer sb = new StringBuffer();

    sb.append(
        "$('"
            + this.ID
            + "').TagBody = \""
            + XString.htmlEncode(getTagBody().replaceAll("\\s+", " "))
            + "\";");
    Object[] ks = this.Params.keyArray();
    Object[] vs = this.Params.valueArray();
    for (int i = 0; i < this.Params.size(); i++) {
      Object key = ks[i];
      if ((key.equals("_SKY_TAGBODY"))
          || (key.toString().startsWith("Cookie."))
          || (key.toString().startsWith("Header."))
          || (vs[i] == null)) continue;
      sb.append(
          "Tree.setParam('"
              + this.ID
              + "','"
              + key
              + "',\""
              + XString.javaEncode(vs[i].toString())
              + "\");");
    }

    sb.append(
        "Tree.setParam('" + this.ID + "','" + "_SKY_TREE_STYLE" + "',\"" + this.style + "\");");
    sb.append("Tree.setParam('" + this.ID + "','" + "_SKY_TREE_LEVEL" + "'," + this.level + ");");
    sb.append("Tree.setParam('" + this.ID + "','" + "_SKY_TREE_LAZY" + "',\"" + this.lazy + "\");");
    sb.append(
        "Tree.setParam('" + this.ID + "','" + "_SKY_TREE_EXPAND" + "',\"" + this.expand + "\");");
    sb.append("Tree.init('" + this.ID + "'," + this.resizeable + ");");
    String content = sb.toString();
    Matcher matcher = Constant.PatternField.matcher(content);
    sb = new StringBuffer();
    int lastEndIndex = 0;
    while (matcher.find(lastEndIndex)) {
      sb.append(content.substring(lastEndIndex, matcher.start()));
      sb.append("$\\{");
      sb.append(matcher.group(1));
      sb.append("}");
      lastEndIndex = matcher.end();
    }
    sb.append(content.substring(lastEndIndex));

    return sb.toString();
  }
Exemple #2
0
  public void setTemplate(HtmlP p) {
    this.onMouseOver = p.getAttribute("onMouseOver");
    this.onMouseOut = p.getAttribute("onMouseOut");
    this.onClick = p.getAttribute("onClick");
    this.onContextMenu = p.getAttribute("onContextMenu");

    p.removeAttribute("onClick");
    p.removeAttribute("onContextMenu");

    this.template = p;
    String html = this.template.getOuterHtml();
    Matcher m = Constant.PatternField.matcher(html);
    int lastEndIndex = 0;

    while (m.find(lastEndIndex)) {
      this.a1.add(html.substring(lastEndIndex, m.start()));
      this.a2.add(m.group(1));
      lastEndIndex = m.end();
    }
    this.a1.add(html.substring(lastEndIndex));
  }