コード例 #1
0
ファイル: HelpLinkTag.java プロジェクト: erland/erlandjava
  public int doStartTag() throws JspException {
    JspWriter out = pageContext.getOut();
    if (Log.isEnabled(this, Log.DEBUG)) {
      Log.println(this, StringUtil.beanToString(this, null, TagSupport.class, true));
    }
    link =
        WebAppEnvironmentPlugin.getEnvironment()
            .getConfigurableResources()
            .getParameter("helppath");

    String onClickMessage = this.onClickMessage;
    if (onClickMessage == null && onClickMessageKey != null) {
      onClickMessage = RequestUtils.message(pageContext, null, null, onClickMessageKey);
    }
    String title = this.title;
    if (title == null && titleKey != null) {
      title = RequestUtils.message(pageContext, null, null, titleKey);
    }
    if (link != null && link.length() > 0) {
      Map parameters = new HashMap();
      if (context != null) {
        parameters.put("context", context);
      }
      link = ServletParameterHelper.replaceDynamicParameters(link, parameters);

      try {
        out.write(
            "<a href=\""
                + addContextPath(link)
                + "\" "
                + (style != null ? "class=\"" + style + "\" " : "")
                + " "
                + (target != null ? " target=\"" + target + "\"" : "")
                + (onClickMessage != null
                    ? " onClick=\"return confirm('" + onClickMessage + "')\""
                    : "")
                + (title != null ? " title=\"" + title + "\" " : "")
                + ">");
        return EVAL_BODY_INCLUDE;
      } catch (IOException e) {
        link = null;
        e
            .printStackTrace(); // To change body of catch statement use File | Settings | File
                                // Templates.
      }
    }
    return SKIP_BODY;
  }