예제 #1
0
 @Override
 public void doTag() throws JspException, IOException {
   StringWriter sw = new StringWriter();
   JspFragment jf = this.getJspBody();
   JspWriter out = getJspContext().getOut();
   jf.invoke(sw);
   String content = sw.toString();
   out.println((content.length() > this.num) ? content.substring(0, this.num) + "..." : content);
 }
  /**
   * Called by the container to invoke this tag. The implementation of this method is provided by
   * the tag library developer, and handles all tag processing, body iteration, etc.
   */
  @Override
  public void doTag() throws JspException {
    JspWriter out = getJspContext().getOut();

    HttpServletRequest request = (HttpServletRequest) ((PageContext) getJspContext()).getRequest();
    String line, requestBody = "", method;

    controller.setHttpRequest(request);

    // set method, requestBody

    // method
    method = request.getMethod().toUpperCase();

    // Requst BODY
    try {
      java.io.BufferedReader br =
          new java.io.BufferedReader(new java.io.InputStreamReader(request.getInputStream()));

      while ((line = br.readLine()) != null) {
        //    System.out.println("line:" + line);
        requestBody += line + "\n";
      }
      br.close();
    } catch (Exception ex) {
      ex.printStackTrace();
    }

    if (controller != null) {

      controller.setRequestBody(requestBody);
      controller.setMethod(method);

      if (method.equals("GET")) {
        controller.doGet();
      } else if (method.equals("POST")) {
        controller.doPost();
      } else if (method.equals("PUT")) {
        controller.doPut();
      } else if (method.equals("DELETE")) {
        controller.doDelete();
      }
    }

    try {

      JspFragment f = getJspBody();
      if (f != null) {
        f.invoke(out);
      }

    } catch (java.io.IOException ex) {
      throw new JspException("Error in RequestTag tag", ex);
    }
  }
 @Override
 public void doTag() throws JspException, IOException {
   JspContext ctx = getJspContext();
   JspWriter w = ctx.getOut();
   w.println("enter TestSimpleTag " + name);
   JspFragment f = getJspBody();
   for (int i = 0; i < bodyLoopCount; ++i) {
     w.println("invoking body i=" + i);
     f.invoke(w);
   }
   w.println("exit TestSimpleTag " + name);
 }
  public void doTag() throws JspException, IOException {
    JspContext jspContext = getJspContext();

    treeTagSupport.doStartTag();

    // Evaluate any nested tags.
    JspFragment jspBody = getJspBody();
    if (jspBody != null) {
      jspBody.invoke(jspContext.getOut());
    }

    treeTagSupport.doEndTag((PageContext) jspContext);
  }
예제 #5
0
  @Override
  public Tag executeTag() throws JspException, IOException {

    JspFragment body = getJspBody();
    if (body != null) {
      body.invoke(null);
    }

    setRandomId("progressgroup");

    Div group = new Div();
    group
        .addAttribute("id", id)
        .addAttribute("style", style)
        .addAttribute("class", Bootstrap.PROGRESS)
        .addAttribute("class", styleClass);

    // Save the differences to calculate the relation
    int total = 0;
    int[] relation = new int[bars.size()];

    for (int i = 0; i < relation.length; i++) {
      int diff = bars.get(i).initIntValues(true);
      relation[i] = diff;
      total += diff;
    }

    // Calculate the percentage of each bar related to total bars and execute tag
    for (int i = 0; i < relation.length; i++) {
      relation[i] = ((100 * relation[i] / total) | 0);

      bars.get(i).setRelation(relation[i]);
      group.addTag(bars.get(i).executeTag());
    }

    appendEvent(group);

    appendAjax(id);
    appendBind(id);

    appendTooltip(group);
    appendPopOver(group);

    if (onInterval != null) {
      appendDocScript(getIntervalScript(relation));
    }
    return group;
  }
예제 #6
0
  private void handleFolder(
      ZFolder folder, JspFragment body, JspContext jctxt, boolean skip, boolean skipsystem)
      throws ServiceException, JspException, IOException {
    if (folder == null) return;

    if (skipsystem && folder.isSystemFolder() && !folder.getId().equals(ZFolder.ID_USER_ROOT))
      return;

    if (mSkipTopSearch
        && (folder instanceof ZSearchFolder)
        && folder.getParentId().equals(ZFolder.ID_USER_ROOT)) return;

    if (mSkipTrash && folder.getId().equals(ZFolder.ID_TRASH)) return;

    if (!skip) {
      jctxt.setAttribute(mVar, new ZFolderBean(folder));
      body.invoke(null);
    }

    if (mExpanded != null && !folder.getSubFolders().isEmpty()) {
      String state = (String) mExpanded.get(folder.getId());
      if (state != null && state.equals("collapse")) return;
    }

    List<ZFolder> subfolders = folder.getSubFolders();
    Collections.sort(subfolders);
    for (ZFolder subfolder : subfolders) {
      if (subfolder != null) handleFolder(subfolder, body, jctxt, false, skipsystem);
    }
  }
  /**
   * Called by the container to invoke this tag. The implementation of this method is provided by
   * the tag library developer, and handles all tag processing, body iteration, etc.
   */
  @Override
  public void doTag() throws JspException, IOException {
    JspWriter out = getJspContext().getOut();
    size = items.size();

    if (size < 5) // an ta products Categories einai ligotera apo 5 ok... print ola
    { // gt an tou kanw print kateu8eian ta 5 tote tha petaei null sta kena
      for (int i = 0; i < size; i++) {
        getJspContext().setAttribute("productCat", items.get(i));
        getJspBody().invoke(null);
      }
    } else {
      for (int i = 0; i < 5; i++) {
        getJspContext().setAttribute("productCat", items.get(i));
        getJspBody().invoke(null);
      }
    }
    JspFragment f = getJspBody();
    if (f != null) {
      f.invoke(out);
    }
  }
예제 #8
0
  @Override
  public void doTag() throws JspException, IOException {
    PageContext pageContext = (PageContext) getJspContext();
    JspWriter out = pageContext.getOut();

    StringWriter sw = new StringWriter();
    sw.append("<script type=\"text/javascript\">");
    sw.append(
        "    var rpxJsHost = ((\"https:\" == document.location.protocol) ? \"https://\" : \"http://static.\");");
    sw.append(
        "    document.write(unescape(\"%3Cscript src='\" + rpxJsHost + \"rpxnow.com/js/lib/rpx.js' type='text/javascript'%3E%3C/script%3E\"));");
    sw.append("</script>");
    sw.append("<script type=\"text/javascript\">\n");
    sw.append("    RPXNOW.overlay = true;\n");

    if (getDefaultProvider() != null && getDefaultProvider().length() > 0) {
      sw.append("    RPXNOW.default_provider = '").append(getDefaultProvider()).append("';\n");
    }

    if (getFlags() != null && getFlags().length() > 0) {
      sw.append("    RPXNOW.flags = '").append(getFlags()).append("';\n");
    }

    if (getLanguagePreference() != null && getLanguagePreference().length() > 0) {
      sw.append("    RPXNOW.language_preference = '")
          .append(getLanguagePreference())
          .append("';\n");
    }

    JspFragment body = getJspBody();
    if (body != null) {
      body.invoke(sw);
    }

    sw.append("</script>");

    out.println(sw.toString());
  }
예제 #9
0
  @Override
  @SuppressWarnings("all")
  public Tag executeTag() throws JspException, IOException {

    // Just to call nested tags
    JspFragment body = getJspBody();
    StringWriter writer = new StringWriter();
    if (body != null) {
      body.invoke(writer);
    }

    setRandomId("output");

    Tag tag = null;

    if (Output.DIV.equalsIgnoreCase(type)) {
      tag = new Tag("div");
    } else if (Output.LEGEND.equalsIgnoreCase(type)) {
      tag = new Tag("legend");
    } else if (Output.STRONG.equalsIgnoreCase(type)) {
      tag = new Tag("strong");
    } else if (Output.MARK.equalsIgnoreCase(type)) {
      tag = new Tag("mark");
    } else if (Output.EM.equalsIgnoreCase(type)) {
      tag = new Tag("em");
    } else if (Output.SMALL.equalsIgnoreCase(type)) {
      tag = new Tag("small");
    } else if (Output.LABEL.equalsIgnoreCase(type)) {
      tag = new Tag("label");
    } else if (Output.OUTPUT.equalsIgnoreCase(type)) {
      tag = new Tag("output");
    } else if (Output.DEL.equalsIgnoreCase(type)) {
      tag = new Tag("del");
    } else if (Output.S.equalsIgnoreCase(type)) {
      tag = new Tag("s");
    } else if (Output.INS.equalsIgnoreCase(type)) {
      tag = new Tag("ins");
    } else if (Output.U.equalsIgnoreCase(type)) {
      tag = new Tag("u");
    } else if (Output.P.equalsIgnoreCase(type)) {
      tag = new Tag("p");
    } else if (Output.H1.equalsIgnoreCase(type)) {
      tag = new Tag("h1");
    } else if (Output.H2.equalsIgnoreCase(type)) {
      tag = new Tag("h2");
    } else if (Output.H3.equalsIgnoreCase(type)) {
      tag = new Tag("h3");
    } else if (Output.H4.equalsIgnoreCase(type)) {
      tag = new Tag("h4");
    } else if (Output.H5.equalsIgnoreCase(type)) {
      tag = new Tag("h5");
    } else if (Output.H6.equalsIgnoreCase(type)) {
      tag = new Tag("h6");
    } else {
      tag = new Span();
    }

    tag.addAttribute("style", getTagValue(style));

    appendRefId(tag, id);
    appendEvent(tag);

    if (Case.CAPITALIZE.equalsIgnoreCase(transform)) {
      tag.addAttribute("class", Bootstrap.TEXT_CAPITALIZE);
    } else if (Case.UPPERCASE.equalsIgnoreCase(transform)) {
      tag.addAttribute("class", Bootstrap.TEXT_UPPERCASE);
    } else if (Case.LOWERCASE.equalsIgnoreCase(transform)) {
      tag.addAttribute("class", Bootstrap.TEXT_LOWERCASE);
    }

    if (Align.LEFT.equalsIgnoreCase(align)) {
      tag.addAttribute("class", Bootstrap.TEXT_LEFT);
    } else if (Align.RIGHT.equalsIgnoreCase(align)) {
      tag.addAttribute("class", Bootstrap.TEXT_RIGHT);
    } else if (Align.CENTER.equalsIgnoreCase(align)) {
      tag.addAttribute("class", Bootstrap.TEXT_CENTER);
    } else if (Align.JUSTIFY.equalsIgnoreCase(align)) {
      tag.addAttribute("class", Bootstrap.TEXT_JUSTIFY);
    }

    String lookVal = (String) getTagValue(look);

    if (Look.PRIMARY.equalsIgnoreCase(lookVal)) {
      tag.addAttribute("class", Bootstrap.TEXT_PRIMARY);
    } else if (Look.SUCCESS.equalsIgnoreCase(lookVal)) {
      tag.addAttribute("class", Bootstrap.TEXT_SUCCESS);
    } else if (Look.INFO.equalsIgnoreCase(lookVal)) {
      tag.addAttribute("class", Bootstrap.TEXT_INFO);
    } else if (Look.WARNING.equalsIgnoreCase(lookVal)) {
      tag.addAttribute("class", Bootstrap.TEXT_WARNING);
    } else if (Look.DANGER.equalsIgnoreCase(lookVal)) {
      tag.addAttribute("class", Bootstrap.TEXT_DANGER);
    } else if (Look.MUTED.equalsIgnoreCase(lookVal)) {
      tag.addAttribute("class", Bootstrap.TEXT_MUTED);
    }

    JspTag parent = getParent();
    if (parent instanceof RowTagHandler) {
      tag.addAttribute("class", Bootstrap.LIST_GROUP_ITEM_TEXT);
    }

    // Add the style class at last
    tag.addAttribute("class", getTagValue(styleClass));

    if (target != null
        && (Output.LABEL.equalsIgnoreCase(type) || Output.OUTPUT.equalsIgnoreCase(type))) {
      tag.addAttribute("for", getTagValue(target));
    }

    String text = writer.toString();
    if (!params.isEmpty() && !text.trim().isEmpty()) {
      text = TextTagHandler.formatText(text, params);
    }

    // Add inner text before the text in the value
    tag.addText(text);

    Object obj = getTagValue(value);
    if (format != null) {
      tag.addText(format.formatValue(obj));

    } else if (obj != null) {
      text = obj.toString();

      if (!params.isEmpty() && !text.trim().isEmpty()) {
        text = TextTagHandler.formatText(text, params);
      }

      if (length != null && length > 0 && text.length() >= length) {
        if (ellipsize && length > 4) {
          text = text.substring(0, length - 4) + " ...";
        } else {
          text = text.substring(0, length);
        }
      }
      tag.addText(text);
    }

    appendAjax(id);
    appendBind(id);

    appendTooltip(tag);
    appendPopOver(tag);

    return tag;
  }
예제 #10
0
  @Override
  public Tag executeTag() throws JspException, IOException {

    // Just to call nested tags
    JspFragment body = getJspBody();
    if (body != null) {
      body.invoke(null);
    }

    setRandomId("textarea");

    Div formGroup = null;

    JspTag parent = getParent();
    if (label != null || parent instanceof FormTagHandler || parent instanceof RestTagHandler) {
      formGroup = new Div();
      formGroup.addAttribute("class", Bootstrap.FORM_GROUP);
    }

    if (label != null) {
      Label labelTag = new Label();
      labelTag
          .addAttribute("for", id)
          .addAttribute("class", Bootstrap.LABEL_CONTROL)
          .addText(getTagValue(label));
      formGroup.addTag(labelTag);
    }

    String name = getTagName(J_TAG, value) + (readOnly ? EL_PARAM_READ_ONLY : "");

    TextArea textArea = new TextArea();
    textArea
        .addAttribute("name", name)
        .addAttribute("style", style)
        .addAttribute("class", Bootstrap.FORM_CONTROL)
        .addAttribute("rows", rows)
        .addAttribute("cols", cols)
        .addAttribute("tabindex", tabIndex)
        .addAttribute("maxlength", length)
        .addAttribute("readonly", readOnly ? readOnly : null)
        .addAttribute("disabled", disabled ? "disabled" : null)
        .addAttribute("placeholder", getTagValue(placeHolder))
        .addText(getTagValue(value));

    appendRefId(textArea, id);

    // Add the style class at last
    textArea.addAttribute("class", styleClass);

    appendValidator(textArea);
    appendRest(textArea, name);
    appendEvent(textArea);

    appendTooltip(textArea);
    appendPopOver(textArea);

    if (formGroup != null) {
      formGroup.addTag(textArea);
    }

    appendAjax(id);
    appendBind(id);

    return formGroup != null ? formGroup : textArea;
  }