Esempio n. 1
0
  private static void append(StringBuffer sb, JavaScript js) {
    sb.append("\n<script type=\"text/javascript\"");
    if (js.getSrc() != null) {
      String url;
      try {
        url = ServletFns.encodeURL(js.getSrc());
      } catch (javax.servlet.ServletException ex) {
        throw new UiException(ex);
      }

      sb.append(" src=\"").append(url).append('"');
      final String charset = js.getCharset();
      if (charset != null) sb.append(" charset=\"").append(charset).append('"');
      sb.append('>');
    } else {
      sb.append(" class=\"z-runonce\">\n")
          // B65-ZK-1836
          .append(js.getContent().replaceAll("</(?i)(?=script>)", "<\\\\/"))
          .append("\n");
    }
    sb.append("</script>");
  }
Esempio n. 2
0
  private static void append(StringBuffer sb, StyleSheet ss, Execution exec, Page page) {
    String href = ss.getHref();
    String media = ss.getMedia();
    if (href != null) {
      try {
        if (exec != null) href = (String) exec.evaluate(page, href, String.class);

        if (href != null && href.length() > 0) {
          sb.append("\n<link rel=\"stylesheet\" type=\"")
              .append(ss.getType())
              .append("\" href=\"")
              .append(ServletFns.encodeURL(href));
          if (media != null) sb.append("\" media=\"").append(media);
          sb.append("\"/>");
        }
      } catch (javax.servlet.ServletException ex) {
        throw new UiException(ex);
      }
    } else {
      sb.append("\n<style");
      if (ss.getType() != null) sb.append(" type=\"").append(ss.getType()).append('"');
      sb.append(">\n").append(ss.getContent()).append("\n</style>");
    }
  }