protected String renderCaptchaTag(
      DDMFormField ddmFormField, DDMFormFieldRenderingContext ddmFormFieldRenderingContext)
      throws Exception {

    CaptchaTag captchaTag = new CaptchaTag();

    captchaTag.setUrl(GetterUtil.getString(ddmFormField.getProperty("url")));

    JspFactory jspFactory = JspFactory.getDefaultFactory();

    HttpServletRequest httpServletRequest = ddmFormFieldRenderingContext.getHttpServletRequest();
    HttpServletResponse httpServletResponse = ddmFormFieldRenderingContext.getHttpServletResponse();

    PageContext pageContext =
        jspFactory.getPageContext(
            new JSPSupportServlet(httpServletRequest.getServletContext()),
            httpServletRequest,
            httpServletResponse,
            null,
            false,
            0,
            false);

    UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();

    unsyncStringWriter.append("<div class=\"form-group\" data-fieldname=\"");
    unsyncStringWriter.append(ddmFormFieldRenderingContext.getName());
    unsyncStringWriter.append("\">");

    captchaTag.setPageContext(new PipingPageContext(pageContext, unsyncStringWriter));

    captchaTag.runTag();

    unsyncStringWriter.append("</div>");

    StringBundler sb = unsyncStringWriter.getStringBundler();

    return sb.toString();
  }
Exemple #2
0
  private String _minifyCss(String content) {
    UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();

    try {
      CssCompressor cssCompressor = new CssCompressor(new UnsyncStringReader(content));

      cssCompressor.compress(unsyncStringWriter, PropsValues.YUI_COMPRESSOR_CSS_LINE_BREAK);
    } catch (Exception e) {
      _log.error("CSS Minifier failed for\n" + content);

      unsyncStringWriter.append(content);
    }

    return unsyncStringWriter.toString();
  }
Exemple #3
0
  private String _minifyJavaScript(String content) {
    UnsyncStringWriter unsyncStringWriter = new UnsyncStringWriter();

    try {
      JavaScriptCompressor javaScriptCompressor =
          new JavaScriptCompressor(new UnsyncStringReader(content), new JavaScriptErrorReporter());

      javaScriptCompressor.compress(
          unsyncStringWriter,
          PropsValues.YUI_COMPRESSOR_JS_LINE_BREAK,
          PropsValues.YUI_COMPRESSOR_JS_MUNGE,
          PropsValues.YUI_COMPRESSOR_JS_VERBOSE,
          PropsValues.YUI_COMPRESSOR_JS_PRESERVE_ALL_SEMICOLONS,
          PropsValues.YUI_COMPRESSOR_JS_DISABLE_OPTIMIZATIONS);
    } catch (Exception e) {
      _log.error("JavaScript Minifier failed for\n" + content);

      unsyncStringWriter.append(content);
    }

    return unsyncStringWriter.toString();
  }