Ejemplo n.º 1
0
 public static String optimizeRelPath(PageContext pc, String relPath) {
   int index;
   String requestURI = relPath, queryString = null;
   if ((index = relPath.indexOf('?')) != -1) {
     requestURI = relPath.substring(0, index);
     queryString = relPath.substring(index + 1);
   }
   PageSource ps = PageSourceImpl.best(((PageContextImpl) pc).getRelativePageSources(requestURI));
   requestURI = ps.getFullRealpath();
   if (queryString != null) return requestURI + "?" + queryString;
   return requestURI;
 }
Ejemplo n.º 2
0
  static void _onRequest(
      PageContext pc, PageSource requestedPage, PageSource application, RequestListener rl)
      throws PageException {
    ((PageContextImpl) pc).setAppListenerType(AppListenerUtil.TYPE_CLASSIC);

    // on requestStart
    if (application != null) pc.doInclude(new PageSource[] {application}, false);

    if (rl != null) {
      requestedPage = rl.execute(pc, requestedPage);
      if (requestedPage == null) return;
    }

    // request
    try {
      pc.doInclude(new PageSource[] {requestedPage}, false);
    } catch (MissingIncludeException mie) {
      ApplicationContext ac = pc.getApplicationContext();
      boolean rethrow = true;
      if (ac instanceof ClassicApplicationContext) {
        ClassicApplicationContext cfc = (ClassicApplicationContext) ac;
        UDF udf = cfc.getOnMissingTemplate();
        if (udf != null) {
          String targetPage = requestedPage.getFullRealpath();
          rethrow = (!Caster.toBooleanValue(udf.call(pc, new Object[] {targetPage}, true), true));
        }
      }
      if (rethrow) throw mie;
    }

    // on Request End
    if (application != null) {
      PageSource onReqEnd = application.getRealPage("OnRequestEnd.cfm");
      if (onReqEnd.exists()) pc.doInclude(new PageSource[] {onReqEnd}, false);
    }
  }