コード例 #1
0
ファイル: ActionInvoker.java プロジェクト: branaway/play
  public static Object[] getActionMethodArgs(Method method, Object o) throws Exception {
    String[] paramsNames = Java.parameterNames(method);
    if (paramsNames == null && method.getParameterTypes().length > 0) {
      throw new UnexpectedException("Parameter names not found for method " + method);
    }

    // Check if we have already performed the bind operation
    Object[] rArgs = CachedBoundActionMethodArgs.current().retrieveActionMethodArgs(method);
    if (rArgs != null) {
      // We have already performed the binding-operation for this method
      // in this request.
      return rArgs;
    }

    rArgs = new Object[method.getParameterTypes().length];
    for (int i = 0; i < method.getParameterTypes().length; i++) {

      Class<?> type = method.getParameterTypes()[i];
      Map<String, String[]> params = new HashMap<String, String[]>();

      // In case of simple params, we don't want to parse the body.
      if (type.equals(String.class) || Number.class.isAssignableFrom(type) || type.isPrimitive()) {
        params.put(paramsNames[i], Scope.Params.current().getAll(paramsNames[i]));
      } else {
        params.putAll(Scope.Params.current().all());
      }
      Logger.trace(
          "getActionMethodArgs name ["
              + paramsNames[i]
              + "] annotation ["
              + Utils.join(method.getParameterAnnotations()[i], " ")
              + "]");

      RootParamNode root = ParamNode.convert(params);
      rArgs[i] =
          Binder.bind(
              root,
              paramsNames[i],
              method.getParameterTypes()[i],
              method.getGenericParameterTypes()[i],
              method.getParameterAnnotations()[i],
              new Binder.MethodAndParamInfo(o, method, i + 1));
    }

    CachedBoundActionMethodArgs.current().storeActionMethodArgs(method, rArgs);
    return rArgs;
  }
コード例 #2
0
ファイル: OpenIDProvider.java プロジェクト: joselaraangel/PDF
 /**
  * Returns the user url (eg: http://user.wordpress.com) for an OpenID service. The method checks
  * if the userFormat has a {username} tag and if it does then looks for the username value in the
  * request parameters.
  *
  * <p>If there is no {username} tag the userFormat is used a passed by the subclass. This is
  * because some providers (eg: google or yahoo) do not need the username in the url.
  *
  * @return The url representing the user.
  */
 protected String getUser() {
   final String user;
   if (needsUsername) {
     final String username = Scope.Params.current().get(OPENID_USER);
     if (username == null || username.trim().length() == 0) {
       Scope.Flash.current().error(Messages.get(SECURESOCIAL_OPEN_ID_USER_NOT_SPECIFIED));
       throw new AuthenticationException();
     }
     user = userFormat.replaceFirst(USERNAME_REGEX, username);
   } else {
     user = userFormat;
   }
   return user;
 }
コード例 #3
0
  /**
   * Génération d'un document de démonstration, affichant une valeur passée en paramètre de la
   * requête HTTP.
   */
  public static void demoRequete() {
    // Récupération du numéro de dossier de la requête, "Inconnu" si non
    // spécifié (pour assurer le bon
    // fonctionnement de la génération du document qui ne permet pas les
    // paramètres non renseignés).
    if (!Scope.Params.current()._contains("numDossier")) {
      Scope.Params.current().put("numDossier", "Inconnu");
    }
    IXDocReport report = XDocReportRegistry.getRegistry().getReport("demoRequete");
    IContext context;
    try {
      context = report.createContext();

      Map<String, String[]> sessionScope = Scope.Params.current().all();
      for (Map.Entry<String, String[]> entry : sessionScope.entrySet()) {
        context.put(entry.getKey(), entry.getValue());
      }

      throw generateReport(report, context);
    } catch (XDocReportException e) {
      // TODO Auto-generated catch block
      e.printStackTrace();
    }
  }
コード例 #4
0
ファイル: SampleTag.java プロジェクト: branaway/pureplay
//
// NOTE: This file was generated from: japidviews/_tags/SampleTag.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class SampleTag extends cn.bran.japid.template.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/_tags/SampleTag.html";

  {
    headers.put("Content-Type", "text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public SampleTag() {
    super(null);
  }

  public SampleTag(StringBuilder out) {
    super(out);
  }

  private String a;

  public cn.bran.japid.template.RenderResult render(String a) {
    this.a = a;
    long t = -1;
    super.layout();
    return new cn.bran.japid.template.RenderResult(this.headers, getOut(), t);
  }

  @Override
  protected void doLayout() {
    // ------
    ; // line 1
    p("Hi "); // line 1
    p(a); // line 2
    p("!\n"); // line 2
  }
}
コード例 #5
0
ファイル: myLayout.java プロジェクト: yanns/Japid
//
// NOTE: This file was generated from: japidviews/more/MyController/myLayout.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public abstract class myLayout extends cn.bran.japid.template.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/more/MyController/myLayout.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public myLayout() {
    super(null);
  }

  public myLayout(StringBuilder out) {
    super(out);
  }

  @Override
  public void layout() {
    p("<p>"); // line 1
    title(); // line 1
    p("</p>\n" + "<p>"); // line 1
    side(); // line 2
    p("</p>\n" + "<p>\n"); // line 2
    doLayout(); // line 4
    p("</p>"); // line 4
  }

  protected void title() {};

  protected void side() {};

  protected abstract void doLayout();
}
コード例 #6
0
ファイル: PlayHandler.java プロジェクト: robfig/play
  protected static Map<String, Object> getBindingForErrors(Exception e, boolean isError) {

    Map<String, Object> binding = new HashMap<String, Object>();
    if (!isError) {
      binding.put("result", e);
    } else {
      binding.put("exception", e);
    }
    binding.put("session", Scope.Session.current());
    binding.put("request", Http.Request.current());
    binding.put("flash", Scope.Flash.current());
    binding.put("params", Scope.Params.current());
    binding.put("play", new Play());
    try {
      binding.put("errors", Validation.errors());
    } catch (Exception ex) {
      // Logger.error(ex, "Error when getting Validation errors");
    }

    return binding;
  }
コード例 #7
0
ファイル: ServletWrapper.java プロジェクト: raff/play
 public void serve404(
     HttpServletRequest servletRequest, HttpServletResponse servletResponse, NotFound e) {
   Logger.warn(
       "404 -> %s %s (%s)",
       servletRequest.getMethod(), servletRequest.getRequestURI(), e.getMessage());
   servletResponse.setStatus(404);
   servletResponse.setContentType("text/html");
   Map<String, Object> binding = new HashMap<String, Object>();
   binding.put("result", e);
   binding.put("session", Scope.Session.current());
   binding.put("request", Http.Request.current());
   binding.put("flash", Scope.Flash.current());
   binding.put("params", Scope.Params.current());
   binding.put("play", new Play());
   try {
     binding.put("errors", Validation.errors());
   } catch (Exception ex) {
     //
   }
   String format = Request.current().format;
   servletResponse.setStatus(404);
   // Do we have an ajax request? If we have then we want to display some text even if it is html
   // that is requested
   if ("XMLHttpRequest".equals(servletRequest.getHeader("X-Requested-With"))
       && (format == null || format.equals("html"))) {
     format = "txt";
   }
   if (format == null) {
     format = "txt";
   }
   servletResponse.setContentType(MimeTypes.getContentType("404." + format, "text/plain"));
   String errorHtml = TemplateLoader.load("errors/404." + format).render(binding);
   try {
     servletResponse.getOutputStream().write(errorHtml.getBytes(Response.current().encoding));
   } catch (Exception fex) {
     Logger.error(fex, "(encoding ?)");
   }
 }
コード例 #8
0
ファイル: ServletWrapper.java プロジェクト: raff/play
 public void serve500(Exception e, HttpServletRequest request, HttpServletResponse response) {
   try {
     Map<String, Object> binding = new HashMap<String, Object>();
     if (!(e instanceof PlayException)) {
       e = new play.exceptions.UnexpectedException(e);
     }
     // Flush some cookies
     try {
       Map<String, Http.Cookie> cookies = Response.current().cookies;
       for (Http.Cookie cookie : cookies.values()) {
         if (cookie.sendOnError) {
           Cookie c = new Cookie(cookie.name, cookie.value);
           c.setSecure(cookie.secure);
           c.setPath(cookie.path);
           if (cookie.domain != null) {
             c.setDomain(cookie.domain);
           }
           response.addCookie(c);
         }
       }
     } catch (Exception exx) {
       // humm ?
     }
     binding.put("exception", e);
     binding.put("session", Scope.Session.current());
     binding.put("request", Http.Request.current());
     binding.put("flash", Scope.Flash.current());
     binding.put("params", Scope.Params.current());
     binding.put("play", new Play());
     try {
       binding.put("errors", Validation.errors());
     } catch (Exception ex) {
       //
     }
     response.setStatus(500);
     String format = "html";
     if (Request.current() != null) {
       format = Request.current().format;
     }
     // Do we have an ajax request? If we have then we want to display some text even if it is html
     // that is requested
     if ("XMLHttpRequest".equals(request.getHeader("X-Requested-With"))
         && (format == null || format.equals("html"))) {
       format = "txt";
     }
     if (format == null) {
       format = "txt";
     }
     response.setContentType(MimeTypes.getContentType("500." + format, "text/plain"));
     try {
       String errorHtml = TemplateLoader.load("errors/500." + format).render(binding);
       response.getOutputStream().write(errorHtml.getBytes(Response.current().encoding));
       Logger.error(e, "Internal Server Error (500)");
     } catch (Throwable ex) {
       Logger.error(e, "Internal Server Error (500)");
       Logger.error(ex, "Error during the 500 response generation");
       throw ex;
     }
   } catch (Throwable exxx) {
     if (exxx instanceof RuntimeException) {
       throw (RuntimeException) exxx;
     }
     throw new RuntimeException(exxx);
   }
 }
コード例 #9
0
ファイル: Posts.java プロジェクト: huangbaihua001/Japid
//
// NOTE: This file was generated from: japidviews/templates/Posts.html
// Change to this file will be lost next time the template file is compiled.
//
public class Posts extends cn.bran.play.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/templates/Posts.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final play.mvc.Http.Request request = play.mvc.Http.Request.current();
  final play.mvc.Http.Response response = play.mvc.Http.Response.current();
  final play.mvc.Scope.Session session = play.mvc.Scope.Session.current();
  final play.mvc.Scope.RenderArgs renderArgs = play.mvc.Scope.RenderArgs.current();
  final play.mvc.Scope.Params params = play.mvc.Scope.Params.current();
  final play.data.validation.Validation validation = play.data.validation.Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public Posts() {
    super(null);
  }

  public Posts(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
        /* args of the template*/
        "blogTitle", "allPost",
      };
  public static final String[] argTypes =
      new String[] {
        /* arg types of the template*/
        "String", "List<Post>",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null, null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.templates.Posts.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private String blogTitle; // line 2
  private List<Post> allPost; // line 2

  public cn.bran.japid.template.RenderResult render(String blogTitle, List<Post> allPost) {
    this.blogTitle = blogTitle;
    this.allPost = allPost;
    long t = -1;
    try {
      super.layout();
    } catch (RuntimeException e) {
      super.handleException(e);
    } // line 2
    return new cn.bran.japid.template.RenderResultPartial(
        getHeaders(), getOut(), t, actionRunners, sourceTemplate);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    // ------
    ; // line 1

    for (Post post : allPost) { // line 4
      p("	- title: "); // line 4
      p(post.title); // line 5
      p("\n" + "	- date: "); // line 5
      p(post.postedAt); // line 6
      p("\n" + "	- author "); // line 6
      p(post.author.name); // line 7
      p(" "); // line 7
      p(post.author.gender); // line 7
      p("\n" + "	the real title: 你好\n"); // line 7
    } // line 9
    p("\n"); // line 9

    endDoLayout(sourceTemplate);
  }
}
コード例 #10
0
ファイル: EachCall.java プロジェクト: viet-nguyen/Japid
//
// NOTE: This file was generated from: japidviews/templates/EachCall.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class EachCall extends cn.bran.play.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/templates/EachCall.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public EachCall() {
    super(null);
  }

  public EachCall(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "posts",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "List<String>",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.templates.EachCall.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private List<String> posts; // line 1

  public cn.bran.japid.template.RenderResult render(List<String> posts) {
    this.posts = posts;
    long t = -1;
    try {
      super.layout();
    } catch (RuntimeException e) {
      super.handleException(e);
    } // line 1
    return new cn.bran.japid.template.RenderResultPartial(
        getHeaders(), getOut(), t, actionRunners, sourceTemplate);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    // ------
    ; // line 1
    p(
        "\n"
            + "<p>\n"
            + "The \"each/Each\" command is a for loop on steroid, with lots of loop information. \n"
            + "</p>\n"
            + "\n"
            + "<p> \n"
            + "The instance variable is defined after the | line, the same way as any tag render-back\n"
            + "</p>\n"
            + "\n"); // line 1
    final Each _Each0 = new Each(getOut());
    _Each0.setOut(getOut());
    _Each0.render( // line 11
        posts,
        new Each.DoBody<String>() { // line 11
          public void render(
              final String p,
              final int _size,
              final int _index,
              final boolean _isOdd,
              final String _parity,
              final boolean _isFirst,
              final boolean _isLast) { // line 11
            // line 11
            p("    <p>index: "); // line 11
            p(_index); // line 12
            p(", parity: "); // line 12
            p(_parity); // line 12
            p(", is odd? "); // line 12
            p(_isOdd); // line 12
            p(", is first? "); // line 12
            p(_isFirst); // line 12
            p(", is last? "); // line 12
            p(_isLast); // line 12
            p(", total size: "); // line 12
            p(_size); // line 12
            p(" </p>\n" + "    call a tag:  "); // line 12
            final SampleTag _SampleTag1 = new SampleTag(getOut());
            _SampleTag1.setActionRunners(getActionRunners()).setOut(getOut());
            _SampleTag1.render(p); // line 13// line 13
          }

          StringBuilder oriBuffer;

          @Override
          public void setBuffer(StringBuilder sb) {
            oriBuffer = getOut();
            setOut(sb);
          }

          @Override
          public void resetBuffer() {
            setOut(oriBuffer);
          }
        }); // line 11
    p("\n"); // line 14
    final SampleTag _SampleTag2 = new SampleTag(getOut());
    _SampleTag2.setActionRunners(getActionRunners()).setOut(getOut());
    _SampleTag2.render("end"); // line 16// line 16
    p(
        "\n"
            + "<p> now we have an enhanced for loop (the \"open for loop\") that also makes all the loop properties available</p>\n"
            + "\n"); // line 16
    int k = 1; // line 20
    final Each _Each3 = new Each(getOut());
    _Each3.setOut(getOut());
    _Each3.render( // line 21
        posts,
        new Each.DoBody<String>() { // line 21
          public void render(
              final String p,
              final int _size,
              final int _index,
              final boolean _isOdd,
              final String _parity,
              final boolean _isFirst,
              final boolean _isLast) { // line 21
            // line 21
            p("    <p>index: "); // line 21
            p(_index); // line 22
            p(", parity: "); // line 22
            p(_parity); // line 22
            p(", is odd? "); // line 22
            p(_isOdd); // line 22
            p(", is first? "); // line 22
            p(_isFirst); // line 22
            p(", is last? "); // line 22
            p(_isLast); // line 22
            p(", total size: "); // line 22
            p(_size); // line 22
            p(" </p>\n" + "    call a tag:  "); // line 22
            final SampleTag _SampleTag4 = new SampleTag(getOut());
            _SampleTag4.setActionRunners(getActionRunners()).setOut(getOut());
            _SampleTag4.render(p); // line 23// line 23
          }

          StringBuilder oriBuffer;

          @Override
          public void setBuffer(StringBuilder sb) {
            oriBuffer = getOut();
            setOut(sb);
          }

          @Override
          public void resetBuffer() {
            setOut(oriBuffer);
          }
        }); // line 21
    p("\n" + "\n"); // line 24
    int[] ints = {1, 2, 3}; // line 27
    final Each _Each5 = new Each(getOut());
    _Each5.setOut(getOut());
    _Each5.render( // line 28
        ints,
        new Each.DoBody<Integer>() { // line 28
          public void render(
              final Integer i,
              final int _size,
              final int _index,
              final boolean _isOdd,
              final String _parity,
              final boolean _isFirst,
              final boolean _isLast) { // line 28
            // line 28
            p("    --> "); // line 28
            p(escape(i)); // line 29
            p("\n"); // line 29
          }

          StringBuilder oriBuffer;

          @Override
          public void setBuffer(StringBuilder sb) {
            oriBuffer = getOut();
            setOut(sb);
          }

          @Override
          public void resetBuffer() {
            setOut(oriBuffer);
          }
        }); // line 28
    ; // line 30

    endDoLayout(sourceTemplate);
  }
}
コード例 #11
0
ファイル: SimpleTemp_txt.java プロジェクト: yanns/Japid
//
// NOTE: This file was generated from: japidviews/templates/SimpleTemp.txt
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class SimpleTemp_txt extends cn.bran.japid.template.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/templates/SimpleTemp.txt";

  {
    putHeader("Content-Type", "text/plain; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public SimpleTemp_txt() {
    super(null);
  }

  public SimpleTemp_txt(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "blogTitle",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "String",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.templates.SimpleTemp_txt.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
  }
  ////// end of named args stuff

  private String blogTitle;

  public cn.bran.japid.template.RenderResult render(String blogTitle) {
    this.blogTitle = blogTitle;
    long t = -1;
    super.layout();
    return new cn.bran.japid.template.RenderResultPartial(getHeaders(), getOut(), t, actionRunners);
  }

  @Override
  protected void doLayout() {
    // ------
    ; // line 1
    p("\n" + "blog title:  "); // line 1
    p(blogTitle); // line 3
    p("\n"); // line 3
  }
}
コード例 #12
0
ファイル: search.java プロジェクト: yanns/Japid
//
// NOTE: This file was generated from: japidviews/Application/search.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class search extends cn.bran.japid.template.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/Application/search.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public search() {
    super(null);
  }

  public search(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
        /* args of the template*/
        "sp",
      };
  public static final String[] argTypes =
      new String[] {
        /* arg types of the template*/
        "SearchParams",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.Application.search.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
  }
  ////// end of named args stuff

  private SearchParams sp;

  public cn.bran.japid.template.RenderResult render(SearchParams sp) {
    this.sp = sp;
    long t = -1;
    super.layout();
    return new cn.bran.japid.template.RenderResultPartial(getHeaders(), getOut(), t, actionRunners);
  }

  @Override
  protected void doLayout() {
    // ------
    ; // line 1
    p("\n" + "\n" + "keys: "); // line 1
    try {
      Object o = sp.keywords;
      if (o.toString().length() == 0) {
        p("没有 keywords");
      } else {
        p(o);
      }
    } catch (NullPointerException npe) {
      p("没有 keywords");
    } // line 3
    p(", mode: "); // line 3
    try {
      Object o = sp.mode;
      if (o.toString().length() == 0) {
        p("no mode");
      } else {
        p(o);
      }
    } catch (NullPointerException npe) {
      p("no mode");
    } // line 3
    p("\n" + "\n" + "true/false: "); // line 3
    p(true ? "class=\"someclass\"" : ""); // line 5
    ; // line 5
  }
}
コード例 #13
0
ファイル: Actions.java プロジェクト: huangbaihua001/Japid
//
// NOTE: This file was generated from: japidviews/templates/Actions.html
// Change to this file will be lost next time the template file is compiled.
//
public class Actions extends cn.bran.play.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/templates/Actions.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final play.mvc.Http.Request request = play.mvc.Http.Request.current();
  final play.mvc.Http.Response response = play.mvc.Http.Response.current();
  final play.mvc.Scope.Session session = play.mvc.Scope.Session.current();
  final play.mvc.Scope.RenderArgs renderArgs = play.mvc.Scope.RenderArgs.current();
  final play.mvc.Scope.Params params = play.mvc.Scope.Params.current();
  final play.data.validation.Validation validation = play.data.validation.Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public Actions() {
    super(null);
  }

  public Actions(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
        /* args of the template*/
        "post",
      };
  public static final String[] argTypes =
      new String[] {
        /* arg types of the template*/
        "models.japidsample.Post",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.templates.Actions.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private models.japidsample.Post post; // line 1

  public cn.bran.japid.template.RenderResult render(models.japidsample.Post post) {
    this.post = post;
    long t = -1;
    try {
      super.layout();
    } catch (RuntimeException e) {
      super.handleException(e);
    } // line 1
    return new cn.bran.japid.template.RenderResultPartial(
        getHeaders(), getOut(), t, actionRunners, sourceTemplate);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    // ------
    ; // line 1
    p("\n" + "\n" + "<form url=\""); // line 1
    p(lookup("showAll", new Object[] {})); // line 4
    p("\"></form>\n" + "<form url=\""); // line 4
    p(lookup("Clients.showAccounts", post.title, post.title)); // line 5
    p("\"></form>\n" + "<form url=\""); // line 5
    p(lookupAbs("Clients.showAccounts", post.title.substring(1, 2))); // line 6
    p("\"></form>\n" + "<form url='"); // line 6
    p(lookupAbs("Clients.showAccounts", new String[] {"aa", "bb"})); // line 7
    p("'></form>\n" + "<form url=\""); // line 7
    p(lookupStatic("/public/stylesheets/main.css")); // line 8
    p("\"></form>\n"); // line 8

    endDoLayout(sourceTemplate);
  }
}
コード例 #14
0
ファイル: testCacheForEager.java プロジェクト: branaway/Japid
//
// NOTE: This file was generated from: japidviews/Application/testCacheForEager.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class testCacheForEager extends cn.bran.play.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/Application/testCacheForEager.html";

  private void initHeaders() {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  {
  }

  // - add implicit fields with Play

  final play.mvc.Http.Request request = play.mvc.Http.Request.current();
  final play.mvc.Http.Response response = play.mvc.Http.Response.current();
  final play.mvc.Scope.Session session = play.mvc.Scope.Session.current();
  final play.mvc.Scope.RenderArgs renderArgs = play.mvc.Scope.RenderArgs.current();
  final play.mvc.Scope.Params params = play.mvc.Scope.Params.current();
  final play.data.validation.Validation validation = play.data.validation.Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public testCacheForEager() {
    super((StringBuilder) null);
    initHeaders();
  }

  public testCacheForEager(StringBuilder out) {
    super(out);
    initHeaders();
  }

  public testCacheForEager(cn.bran.japid.template.JapidTemplateBaseWithoutPlay caller) {
    super(caller);
  }

  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "a",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "String",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.Application.testCacheForEager.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private String a; // line 1, japidviews/Application/testCacheForEager.html

  public cn.bran.japid.template.RenderResult render(String a) {
    this.a = a;
    try {
      super.layout();
    } catch (RuntimeException __e) {
      super.handleException(__e);
    } // line 1, japidviews/Application/testCacheForEager.html
    return getRenderResult();
  }

  public static cn.bran.japid.template.RenderResult apply(String a) {
    return new testCacheForEager().render(a);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    ; // line 1, testCacheForEager.html
    p("\n" + "<html>\n" + "\n" + "<body>\n" + "	hello "); // line 1, testCacheForEager.html
    p(a); // line 6, testCacheForEager.html
    p(", now seconds is "); // line 6, testCacheForEager.html
    actionRunners.put(
        getOut().length(),
        new cn.bran.play.CacheablePlayActionRunner("", Application.class, "seconds", "") {
          @Override
          public void runPlayAction() throws cn.bran.play.JapidResult {
            Application.seconds(); // line 6, testCacheForEager.html
          }
        });
    p("\n"); // line 6, testCacheForEager.html
    p("\n" + "</body>\n" + "</html>"); // line 6, testCacheForEager.html

    endDoLayout(sourceTemplate);
  }
}
コード例 #15
0
ファイル: index_xml.java プロジェクト: branaway/Japid
//
// NOTE: This file was generated from: japidviews/more/ContentNegotiation/index.xml
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class index_xml extends cn.bran.play.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/more/ContentNegotiation/index.xml";

  private void initHeaders() {
    putHeader("Content-Type", "text/xml; charset=utf-8");
    setContentType("text/xml; charset=utf-8");
  }

  {
  }

  // - add implicit fields with Play

  final play.mvc.Http.Request request = play.mvc.Http.Request.current();
  final play.mvc.Http.Response response = play.mvc.Http.Response.current();
  final play.mvc.Scope.Session session = play.mvc.Scope.Session.current();
  final play.mvc.Scope.RenderArgs renderArgs = play.mvc.Scope.RenderArgs.current();
  final play.mvc.Scope.Params params = play.mvc.Scope.Params.current();
  final play.data.validation.Validation validation = play.data.validation.Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public index_xml() {
    super((StringBuilder) null);
    initHeaders();
  }

  public index_xml(StringBuilder out) {
    super(out);
    initHeaders();
  }

  public index_xml(cn.bran.japid.template.JapidTemplateBaseWithoutPlay caller) {
    super(caller);
  }

  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames = new String[] {
        /* args of the template*/
      };
  public static final String[] argTypes = new String[] {
        /* arg types of the template*/
      };
  public static final Object[] argDefaults = new Object[] {};
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.more.ContentNegotiation.index_xml.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  public cn.bran.japid.template.RenderResult render() {
    try {
      super.layout();
    } catch (RuntimeException __e) {
      super.handleException(__e);
    } // line 0, japidviews/more/ContentNegotiation/index.xml
    return getRenderResult();
  }

  public static cn.bran.japid.template.RenderResult apply() {
    return new index_xml().render();
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    p("<format>\n"); // line 1, index.xml
    p(request.format); // line 2, index.xml
    p("\n" + "</format>"); // line 2, index.xml

    endDoLayout(sourceTemplate);
  }
}
コード例 #16
0
ファイル: decorateName.java プロジェクト: efficacy/Japid
//
// NOTE: This file was generated from: japidviews/Application/decorateName.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class decorateName extends cn.bran.play.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/Application/decorateName.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public decorateName() {
    super(null);
  }

  public decorateName(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "s",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "String",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.Application.decorateName.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private String s;

  public cn.bran.japid.template.RenderResult render(String s) {
    this.s = s;
    long t = -1;
    try {
      super.layout();
    } catch (RuntimeException e) {
      super.handleException(e);
    }
    return new cn.bran.japid.template.RenderResultPartial(getHeaders(), getOut(), t, actionRunners);
  }

  @Override
  protected void doLayout() {
    // ------
    ; // line 1
    p("\n" + "^^^_ "); // line 1
    p(s); // line 3
    p(" _^^^\n"); // line 3
  }
}
コード例 #17
0
//
// NOTE: This file was generated from: japidviews/_tags/paramWithDefaults.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class paramWithDefaults extends cn.bran.play.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/_tags/paramWithDefaults.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public paramWithDefaults() {
    super(null);
  }

  public paramWithDefaults(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
        /* args of the template*/
        "msg", "m2", "age",
      };
  public static final String[] argTypes =
      new String[] {
        /* arg types of the template*/
        "String", "String", "Integer",
      };
  public static final Object[] argDefaults =
      new Object[] {
        "message 1 default value", new String("m2message"), 20,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews._tags.paramWithDefaults.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private String msg; // line 1
  private String m2; // line 1
  private Integer age; // line 1

  public cn.bran.japid.template.RenderResult render(String msg, String m2, Integer age) {
    this.msg = msg;
    this.m2 = m2;
    this.age = age;
    long t = -1;
    try {
      super.layout();
    } catch (RuntimeException e) {
      super.handleException(e);
    } // line 1
    return new cn.bran.japid.template.RenderResultPartial(
        getHeaders(), getOut(), t, actionRunners, sourceTemplate);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    // ------
    ; // line 1
    p("\n" + "<span>"); // line 5
    p(msg); // line 6
    p("</span>\n" + "<span>"); // line 6
    p(m2); // line 7
    p("</span>\n" + "<span>"); // line 7
    p(age); // line 8
    p("</span>\n" + "\n"); // line 8

    endDoLayout(sourceTemplate);
  }
}
コード例 #18
0
//
// NOTE: This file was generated from: japidviews/AdminController/flashPurchaseList.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class flashPurchaseList extends backStageLayout {
  public static final String sourceTemplate = "japidviews/AdminController/flashPurchaseList.html";

  private void initHeaders() {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  {
  }

  // - add implicit fields with Play

  final play.mvc.Http.Request request = play.mvc.Http.Request.current();
  final play.mvc.Http.Response response = play.mvc.Http.Response.current();
  final play.mvc.Scope.Session session = play.mvc.Scope.Session.current();
  final play.mvc.Scope.RenderArgs renderArgs = play.mvc.Scope.RenderArgs.current();
  final play.mvc.Scope.Params params = play.mvc.Scope.Params.current();
  final play.data.validation.Validation validation = play.data.validation.Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public flashPurchaseList() {
    super((StringBuilder) null);
    initHeaders();
  }

  public flashPurchaseList(StringBuilder out) {
    super(out);
    initHeaders();
  }

  public flashPurchaseList(cn.bran.japid.template.JapidTemplateBaseWithoutPlay caller) {
    super(caller);
  }

  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "announcementList", "currentPage", "totalPage",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "List<Announcements>", "int", "int",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null, null, null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.AdminController.flashPurchaseList.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private List<Announcements>
      announcementList; // line 3, japidviews/AdminController/flashPurchaseList.html
  private int currentPage; // line 3, japidviews/AdminController/flashPurchaseList.html
  private int totalPage; // line 3, japidviews/AdminController/flashPurchaseList.html

  public cn.bran.japid.template.RenderResult render(
      List<Announcements> announcementList, int currentPage, int totalPage) {
    this.announcementList = announcementList;
    this.currentPage = currentPage;
    this.totalPage = totalPage;
    try {
      super.layout();
    } catch (RuntimeException __e) {
      super.handleException(__e);
    } // line 3, japidviews/AdminController/flashPurchaseList.html
    return getRenderResult();
  }

  public static cn.bran.japid.template.RenderResult apply(
      List<Announcements> announcementList, int currentPage, int totalPage) {
    return new flashPurchaseList().render(announcementList, currentPage, totalPage);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    ; // line 1, japidviews\AdminController\flashPurchaseList.html
    // line 6, japidviews\AdminController\flashPurchaseList.html
    // line 7, japidviews\AdminController\flashPurchaseList.html
    p(
        "<div class=\"navbar-inner\">\n"
            + "</div>\n"
            + "<div class=\"container\">\n"
            + "	<!-- 左菜单 -->\n"
            + "	"); // line 11, japidviews\AdminController\flashPurchaseList.html
    new leftMenusTag(flashPurchaseList.this)
        .render(); // line 16, japidviews\AdminController\flashPurchaseList.html// line 16,
                   // japidviews\AdminController\flashPurchaseList.html
    p(
        "    	<!-- 主内容 -->\n"
            + "		  <div class=\"content\" id=\"content\">\n"
            + "            <!-- 标题 -->\n"
            + "            <h3 class=\"title add-commodity-title\">活动列表</h3>\n"
            + "			"); // line 16, japidviews\AdminController\flashPurchaseList.html
    p(
        "            <!-- table -->\n"
            + "            <table class=\"table\">\n"
            + "                <tr>\n"
            + "                    <th>活动名称</th>\n"
            + "                    <th>开始时间</th>\n"
            + "                    <th>结束时间</th>\n"
            + "                    <th class=\"handle-w1\">操作</th>\n"
            + "                </tr>\n"
            + "                "); // line 24, japidviews\AdminController\flashPurchaseList.html
    if (!announcementList.isEmpty()) { // line 33, japidviews\AdminController\flashPurchaseList.html
      for (Announcements announcements :
          announcementList) { // line 34, japidviews\AdminController\flashPurchaseList.html
        p(
            "                	<tr>\n"
                + "                    <td>"); // line 34,
                                               // japidviews\AdminController\flashPurchaseList.html
        p(announcements.title); // line 36, japidviews\AdminController\flashPurchaseList.html
        p(
            "</td>\n"
                + "                    <td>"); // line 36,
                                               // japidviews\AdminController\flashPurchaseList.html
        p(announcements.startTime); // line 37, japidviews\AdminController\flashPurchaseList.html
        p(
            "</td>\n"
                + "                    <td>"); // line 37,
                                               // japidviews\AdminController\flashPurchaseList.html
        p(announcements.endTime); // line 38, japidviews\AdminController\flashPurchaseList.html
        p(
            "</td>\n"
                + "                    <td>\n"
                + "                    	<a id=\"preview\" href=\""); // line 38,
                                                                     // japidviews\AdminController\flashPurchaseList.html
        p(
            lookup(
                "AdminController.preview",
                announcements.id)); // line 40, japidviews\AdminController\flashPurchaseList.html
        p(
            "\" class=\"defaultBtn btn-sm btn-green\">预览</a>\n"
                + "                        <a id=\"del\" href=\""); // line 40,
                                                                    // japidviews\AdminController\flashPurchaseList.html
        p(
            lookup(
                "AdminController.deleteFastGood",
                announcements.id)); // line 41, japidviews\AdminController\flashPurchaseList.html
        p(
            "\" class=\"defaultBtn btn-sm btn-red\">删除</a>\n"
                + "                    </td>\n"
                + "                </tr>\n"
                + "                "); // line 41, japidviews\AdminController\flashPurchaseList.html
      } // line 44, japidviews\AdminController\flashPurchaseList.html
    } // line 45, japidviews\AdminController\flashPurchaseList.html
    p(
        "            </table>\n"
            + "            "); // line 45, japidviews\AdminController\flashPurchaseList.html
    new pagination(flashPurchaseList.this)
        .render(
            getUrl(),
            "page",
            currentPage,
            totalPage,
            null); // line 47, japidviews\AdminController\flashPurchaseList.html// line 47,
                   // japidviews\AdminController\flashPurchaseList.html
    // line 48, japidviews\AdminController\flashPurchaseList.html
    p(
        "            <!-- h20 -->\n"
            + "            <div class=\"h20\"></div>\n"
            + "		</div>\n"
            + "\n"
            + "    </div>\n"
            + "</body>\n"
            + "</html>"); // line 50, japidviews\AdminController\flashPurchaseList.html

    endDoLayout(sourceTemplate);
  }

  @Override
  protected void moreJSLink() {
    // line 7, japidviews\AdminController\flashPurchaseList.html
    p(
        "<script>\n"
            + "    main.setSidebarHover(\"index\");\n"
            + "</script>\n"); // line 7, japidviews\AdminController\flashPurchaseList.html
    ;
  }

  @Override
  protected void title() {
    // line 6, japidviews\AdminController\flashPurchaseList.html
    p("后台管理-活动列表"); // line 6, japidviews\AdminController\flashPurchaseList.html
    ;
  }

  public String getUrl() {
    StringBuilder sb = new StringBuilder();
    StringBuilder ori = getOut();
    this.setOut(sb);
    TreeMap<Integer, cn.bran.japid.template.ActionRunner> parentActionRunners = actionRunners;
    actionRunners = new TreeMap<Integer, cn.bran.japid.template.ActionRunner>();
    // line 48, japidviews\AdminController\flashPurchaseList.html
    p("            	"); // line 48, japidviews\AdminController\flashPurchaseList.html
    p(
        lookup(
            "AdminController.flashPurchaseList",
            new Object[] {})); // line 49, japidviews\AdminController\flashPurchaseList.html
    p("            "); // line 49, japidviews\AdminController\flashPurchaseList.html

    this.setOut(ori);
    if (actionRunners.size() > 0) {
      StringBuilder _sb2 = new StringBuilder();
      int segStart = 0;
      for (Map.Entry<Integer, cn.bran.japid.template.ActionRunner> _arEntry :
          actionRunners.entrySet()) {
        int pos = _arEntry.getKey();
        _sb2.append(sb.substring(segStart, pos));
        segStart = pos;
        cn.bran.japid.template.ActionRunner _a_ = _arEntry.getValue();
        _sb2.append(_a_.run().getContent().toString());
      }
      _sb2.append(sb.substring(segStart));
      actionRunners = parentActionRunners;
      return _sb2.toString();
    } else {
      actionRunners = parentActionRunners;
      return sb.toString();
    }
  }
}
コード例 #19
0
ファイル: Set.java プロジェクト: gslowikowski/Japid
//
// NOTE: This file was generated from: japidviews/templates/Set.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class Set extends japidviews._layouts.SetLayout {
  public static final String sourceTemplate = "japidviews/templates/Set.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public Set() {
    super(null);
  }

  public Set(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "a",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "String",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.templates.Set.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private String a; // line 2

  public cn.bran.japid.template.RenderResult render(String a) {
    this.a = a;
    long t = -1;
    try {
      super.layout();
    } catch (RuntimeException e) {
      super.handleException(e);
    } // line 2
    return new cn.bran.japid.template.RenderResultPartial(
        getHeaders(), getOut(), t, actionRunners, sourceTemplate);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    // ------
    ; // line 1
    p("\n"); // line 2
    p("\n" + "\n"); // line 11
    p("\n" + "\n"); // line 13

    // line 17

    endDoLayout(sourceTemplate);
  }

  @Override
  protected void footer() {
    // line 17
    p("    great footer. Call a tag: "); // line 17
    final dummyTag _dummyTag2 = new dummyTag(getOut());
    _dummyTag2.setActionRunners(getActionRunners()).setOut(getOut());
    _dummyTag2.render("me"); // line 18// line 18
    ;
  }

  @Override
  protected void title() {
    p("Home away" + a);
    ;
  }
}
コード例 #20
0
ファイル: picka.java プロジェクト: yanns/Japid
//
// NOTE: This file was generated from: japidviews/_tags/picka.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class picka extends cn.bran.japid.template.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/_tags/picka.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public picka() {
    super(null);
  }

  public picka(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "a", "b",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "String", "String",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null, null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews._tags.picka.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
  }
  ////// end of named args stuff

  private String a;
  private String b;

  public cn.bran.japid.template.RenderResult render(
      DoBody body, cn.bran.japid.compiler.NamedArgRuntime... named) {
    Object[] args = buildArgs(named, body);
    return runRenderer(args);
  }

  private DoBody body;

  public static interface DoBody<A> {
    void render(A a);
  }

  public cn.bran.japid.template.RenderResult render(String a, String b, DoBody body) {
    this.body = body;
    this.a = a;
    this.b = b;
    long t = -1;
    super.layout();
    return new cn.bran.japid.template.RenderResultPartial(getHeaders(), getOut(), t, actionRunners);
  }

  @Override
  protected void doLayout() {
    // ------
    ; // line 1
    p("<p>\n" + "some text \n" + "</p>\n" + "<p>\n"); // line 1
    if (body != null) body.render(a + b);
    p("</p>\n" + "<p>\n" + "more text \n" + "</p>\n" + " "); // line 6
  }
}
コード例 #21
0
ファイル: panel2.java プロジェクト: viet-nguyen/Japid
//
// NOTE: This file was generated from: japidviews/more/Portlets/panel2.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class panel2 extends cn.bran.play.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/more/Portlets/panel2.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public panel2() {
    super(null);
  }

  public panel2(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "a",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "String",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.more.Portlets.panel2.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private String a; // line 1

  public cn.bran.japid.template.RenderResult render(String a) {
    this.a = a;
    long t = -1;
    try {
      super.layout();
    } catch (RuntimeException e) {
      super.handleException(e);
    } // line 1
    return new cn.bran.japid.template.RenderResultPartial(
        getHeaders(), getOut(), t, actionRunners, sourceTemplate);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    // ------
    ; // line 1
    p("<p>panel-2 "); // line 1
    p(a); // line 2
    p(": "); // line 2
    p(new Date()); // line 2
    p("</p>\n"); // line 2

    endDoLayout(sourceTemplate);
  }
}
コード例 #22
0
ファイル: subview.java プロジェクト: branaway/Japid
//
// NOTE: This file was generated from: japidviews/more/MyController/subview.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class subview extends superview {
  public static final String sourceTemplate = "japidviews/more/MyController/subview.html";

  private void initHeaders() {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  {
  }

  // - add implicit fields with Play

  final play.mvc.Http.Request request = play.mvc.Http.Request.current();
  final play.mvc.Http.Response response = play.mvc.Http.Response.current();
  final play.mvc.Scope.Session session = play.mvc.Scope.Session.current();
  final play.mvc.Scope.RenderArgs renderArgs = play.mvc.Scope.RenderArgs.current();
  final play.mvc.Scope.Params params = play.mvc.Scope.Params.current();
  final play.data.validation.Validation validation = play.data.validation.Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public subview() {
    super((StringBuilder) null);
    initHeaders();
  }

  public subview(StringBuilder out) {
    super(out);
    initHeaders();
  }

  public subview(cn.bran.japid.template.JapidTemplateBaseWithoutPlay caller) {
    super(caller);
  }

  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
        /* args of the template*/
        "s",
      };
  public static final String[] argTypes =
      new String[] {
        /* arg types of the template*/
        "String",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.more.MyController.subview.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private String s; // line 2, japidviews/more/MyController/subview.html

  public cn.bran.japid.template.RenderResult render(String s) {
    this.s = s;
    try {
      super.layout();
    } catch (RuntimeException __e) {
      super.handleException(__e);
    } // line 2, japidviews/more/MyController/subview.html
    return getRenderResult();
  }

  public static cn.bran.japid.template.RenderResult apply(String s) {
    return new subview().render(s);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    ; // line 1, subview.html
    ; // line 2, subview.html
    // line 4, subview.html
    ; // line 4, subview.html
    // line 5, subview.html
    p("\n" + "\n" + "hello "); // line 5, subview.html
    p(s); // line 8, subview.html
    p("\n"); // line 8, subview.html
    new japidviews.more.MyController._tags.taggy(subview.this)
        .render(s); // line 10, subview.html// line 10, subview.html
    p(" "); // line 10, subview.html

    endDoLayout(sourceTemplate);
  }

  @Override
  protected void side() {
    p("my side bar");
    ;
  }

  @Override
  protected void title() {
    p("my title from subview");
    ;
  }
}
コード例 #23
0
//
// NOTE: This file was generated from: japidviews/templates/invokeInLoop.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class invokeInLoop extends cn.bran.play.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/templates/invokeInLoop.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final play.mvc.Http.Request request = play.mvc.Http.Request.current();
  final play.mvc.Http.Response response = play.mvc.Http.Response.current();
  final play.mvc.Scope.Session session = play.mvc.Scope.Session.current();
  final play.mvc.Scope.RenderArgs renderArgs = play.mvc.Scope.RenderArgs.current();
  final play.mvc.Scope.Params params = play.mvc.Scope.Params.current();
  final play.data.validation.Validation validation = play.data.validation.Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public invokeInLoop() {
    super(null);
  }

  public invokeInLoop(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "posts",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "List<Post>",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.templates.invokeInLoop.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private List<Post> posts; // line 2

  public cn.bran.japid.template.RenderResult render(List<Post> posts) {
    this.posts = posts;
    long t = -1;
    try {
      super.layout();
    } catch (RuntimeException e) {
      super.handleException(e);
    } // line 2
    return new cn.bran.japid.template.RenderResultPartial(
        getHeaders(), getOut(), t, actionRunners, sourceTemplate);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    // ------
    ; // line 1
    p("\n"); // line 2
    p("\n" + "\n"); // line 7
    for (int i = 0; i < 3; i++) { // line 9
      final int j = i; // line 10
      p("	"); // line 10
      actionRunners.put(
          getOut().length(),
          new cn.bran.play.CacheablePlayActionRunner("", Application.class, "echo", j) {
            @Override
            public void runPlayAction() throws cn.bran.play.JapidResult {
              Application.echo(j); // line 11
            }
          });
      p("\n"); // line 11
      p("\n"); // line 11
    } // line 12
    p("<p/>\n"); // line 12
    p("\n" + "\n"); // line 14
    for (final Post p : posts) { // line 16
      p("    another notation for invoking actions:  \n" + "    "); // line 16
      actionRunners.put(
          getOut().length(),
          new cn.bran.play.CacheablePlayActionRunner("", Application.class, "echoPost", p) {
            @Override
            public void runPlayAction() throws cn.bran.play.JapidResult {
              Application.echoPost(p); // line 18
            }
          });
      p("\n"); // line 18
    } // line 19
    ; // line 19

    endDoLayout(sourceTemplate);
  }
}
コード例 #24
0
ファイル: AllPost2.java プロジェクト: viet-nguyen/Japid
//
// NOTE: This file was generated from: japidviews/templates/AllPost2.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class AllPost2 extends Layout {
  public static final String sourceTemplate = "japidviews/templates/AllPost2.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public AllPost2() {
    super(null);
  }

  public AllPost2(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "blogTitle", "allPost",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "String", "List<Post>",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null, null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.templates.AllPost2.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  private String blogTitle; // line 3
  private List<Post> allPost; // line 3

  public cn.bran.japid.template.RenderResult render(String blogTitle, List<Post> allPost) {
    this.blogTitle = blogTitle;
    this.allPost = allPost;
    long t = -1;
    try {
      super.layout();
    } catch (RuntimeException e) {
      super.handleException(e);
    } // line 3
    return new cn.bran.japid.template.RenderResultPartial(
        getHeaders(), getOut(), t, actionRunners, sourceTemplate);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    // ------
    ; // line 1
    p("\n"); // line 3
    p("\n" + "\n"); // line 5
    if (allPost.size() > 0) { // line 8
      p("	<p></p>\n" + "	"); // line 8
      for (Post p : allPost) { // line 10
        p("	    "); // line 10
        final Display _Display1 = new Display(getOut());
        _Display1.setActionRunners(getActionRunners()).setOut(getOut());
        _Display1.render( // line 11
            new Display.DoBody<String>() { // line 11
              public void render(final String title) { // line 11
                // line 11
                p("			<p>The real title is: "); // line 11
                p(title); // line 12
                p(";</p>\n" + "	    "); // line 12
              }

              StringBuilder oriBuffer;

              @Override
              public void setBuffer(StringBuilder sb) {
                oriBuffer = getOut();
                setOut(sb);
              }

              @Override
              public void resetBuffer() {
                setOut(oriBuffer);
              }
            },
            named("post", p),
            named("as", "home")); // line 11
        p("	"); // line 13
      } // line 14
    } else { // line 15
      p("	<p>There is no post at this moment</p>\n"); // line 15
    } // line 17
    p("\n"); // line 17
    final Tag2 _Tag22 = new Tag2(getOut());
    _Tag22.setActionRunners(getActionRunners()).setOut(getOut());
    _Tag22.render(named("msg", blogTitle), named("age", 1000)); // line 19// line 19
    p("\n" + "<p>end of it</p>"); // line 19

    endDoLayout(sourceTemplate);
  }

  @Override
  protected void title() {
    p("Home");
    ;
  }
}
コード例 #25
0
ファイル: def.java プロジェクト: efficacy/Japid
//
// NOTE: This file was generated from: japidviews/templates/def.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class def extends defLayout {
  public static final String sourceTemplate = "japidviews/templates/def.html";

  {
    putHeader("Content-Type", "text/html; charset=utf-8");
  }

  // - add implicit fields with Play

  final Request request = Request.current();
  final Response response = Response.current();
  final Session session = Session.current();
  final RenderArgs renderArgs = RenderArgs.current();
  final Params params = Params.current();
  final Validation validation = Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public def() {
    super(null);
  }

  public def(StringBuilder out) {
    super(out);
  }
  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames = new String[] {
        /* args of the template*/
      };
  public static final String[] argTypes = new String[] {
        /* arg types of the template*/
      };
  public static final Object[] argDefaults = new Object[] {};
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews.templates.def.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  public cn.bran.japid.template.RenderResult render() {
    long t = -1;
    try {
      super.layout();
    } catch (RuntimeException e) {
      super.handleException(e);
    }
    return new cn.bran.japid.template.RenderResultPartial(getHeaders(), getOut(), t, actionRunners);
  }

  @Override
  protected void doLayout() {

    // -- set up the tag objects
    final dummyTag _dummyTag4 = new dummyTag(getOut());
    {
      _dummyTag4.setActionRunners(getActionRunners());
    }

    // -- end of the tag objects

    // ------
    ; // line 1
    p("\n" + "<p>check 1</p>\n"); // line 1
    p("\n" + "\n" + "\n"); // line 4
    // line 7
    p("\n" + "<p>check 2</p>\n"); // line 12
    // line 15
    p("<p>check 3</p>\n" + "\n"); // line 18
    p("\n" + "\n"); // line 21
    // line 23
    p("\n" + "\n" + "<p>check 4</p>\n"); // line 26
    _dummyTag4.setOut(getOut());
    _dummyTag4.render(get("bar")); // line 29
    p("\n" + "\n"); // line 29
    p("<p>check 5</p>\n" + "\n"); // line 31
    p(foo()); // line 34
    p("\n" + "\n" + "<p>check 6</p>\n" + "\n"); // line 34
    String a = "";
    // line 39
    a += "bssdfsdf";
    // line 40
    p("\n"); // line 41
    if (a.length() > 0) { // line 42
      p(a); // line 43
    } // line 44
    p("\n"); // line 44
  }

  public String foo2(String p) {
    StringBuilder sb = new StringBuilder();
    StringBuilder ori = getOut();
    this.setOut(sb);
    final dummyTag _dummyTag1 = new dummyTag(getOut());
    {
      _dummyTag1.setActionRunners(getActionRunners());
    }

    // line 7
    p("	<p>hi "); // line 7
    p(p); // line 8
    p("!,</p> \n" + "	<p>from "); // line 8
    p(request.action); // line 9
    p("</p>\n" + "	<p>OK you can call a tag:</p>\n" + "	"); // line 9
    _dummyTag1.setOut(getOut());
    _dummyTag1.render(p); // line 11

    this.setOut(ori);
    return sb.toString();
  }

  public String foo() {
    StringBuilder sb = new StringBuilder();
    StringBuilder ori = getOut();
    this.setOut(sb);
    // line 15
    p("	"); // line 15
    String s = "hi there"; // line 16
    p("	<p>foo hello "); // line 16
    p(foo2(s)); // line 17
    p("</p>\n"); // line 17

    this.setOut(ori);
    return sb.toString();
  }

  public String bar() {
    StringBuilder sb = new StringBuilder();
    StringBuilder ori = getOut();
    this.setOut(sb);
    // line 23
    p("\n" + "	"); // line 23
    String s = "hi2"; // line 24
    p("	<p>bar hi "); // line 24
    p(s); // line 25
    p("!</p>\n"); // line 25

    this.setOut(ori);
    return sb.toString();
  }
}
コード例 #26
0
ファイル: picka.java プロジェクト: branaway/Japid
//
// NOTE: This file was generated from: japidviews/_tags/picka.html
// Change to this file will be lost next time the template file is compiled.
//
@cn.bran.play.NoEnhance
public class picka extends cn.bran.play.JapidTemplateBase {
  public static final String sourceTemplate = "japidviews/_tags/picka.html";

  private void initHeaders() {
    putHeader("Content-Type", "text/html; charset=utf-8");
    setContentType("text/html; charset=utf-8");
  }

  {
  }

  // - add implicit fields with Play

  final play.mvc.Http.Request request = play.mvc.Http.Request.current();
  final play.mvc.Http.Response response = play.mvc.Http.Response.current();
  final play.mvc.Scope.Session session = play.mvc.Scope.Session.current();
  final play.mvc.Scope.RenderArgs renderArgs = play.mvc.Scope.RenderArgs.current();
  final play.mvc.Scope.Params params = play.mvc.Scope.Params.current();
  final play.data.validation.Validation validation = play.data.validation.Validation.current();
  final cn.bran.play.FieldErrors errors = new cn.bran.play.FieldErrors(validation);
  final play.Play _play = new play.Play();

  // - end of implicit fields with Play

  public picka() {
    super((StringBuilder) null);
    initHeaders();
  }

  public picka(StringBuilder out) {
    super(out);
    initHeaders();
  }

  public picka(cn.bran.japid.template.JapidTemplateBaseWithoutPlay caller) {
    super(caller);
  }

  /* based on https://github.com/branaway/Japid/issues/12
   */
  public static final String[] argNames =
      new String[] {
          /* args of the template*/
        "a", "b",
      };
  public static final String[] argTypes =
      new String[] {
          /* arg types of the template*/
        "String", "String",
      };
  public static final Object[] argDefaults =
      new Object[] {
        null, null,
      };
  public static java.lang.reflect.Method renderMethod =
      getRenderMethod(japidviews._tags.picka.class);

  {
    setRenderMethod(renderMethod);
    setArgNames(argNames);
    setArgTypes(argTypes);
    setArgDefaults(argDefaults);
    setSourceTemplate(sourceTemplate);
  }
  ////// end of named args stuff

  {
    setHasDoBody();
  }

  private String a; // line 1, japidviews/_tags/picka.html
  private String b; // line 1, japidviews/_tags/picka.html

  public cn.bran.japid.template.RenderResult render(
      DoBody body, cn.bran.japid.compiler.NamedArgRuntime... named) {
    Object[] args = buildArgs(named, body);
    try {
      return runRenderer(args);
    } catch (RuntimeException e) {
      handleException(e);
      throw e;
    } // line 1, japidviews/_tags/picka.html
  }

  private DoBody body;

  public static interface DoBody<A> {
    void render(A a);

    void setBuffer(StringBuilder sb);

    void resetBuffer();
  }

  <A> String renderBody(A a) {
    StringBuilder sb = new StringBuilder();
    if (body != null) {
      body.setBuffer(sb);
      body.render(a);
      body.resetBuffer();
    }
    return sb.toString();
  }

  public cn.bran.japid.template.RenderResult render(String a, String b, DoBody body) {
    this.body = body;
    this.a = a;
    this.b = b;
    try {
      super.layout();
    } catch (RuntimeException __e) {
      super.handleException(__e);
    } // line 1, japidviews/_tags/picka.html
    return getRenderResult();
  }

  public cn.bran.japid.template.RenderResult render(String a, String b) {
    this.a = a;
    this.b = b;
    try {
      super.layout();
    } catch (RuntimeException __e) {
      super.handleException(__e);
    } // line 1, japidviews/_tags/picka.html
    return getRenderResult();
  }

  public static cn.bran.japid.template.RenderResult apply(String a, String b) {
    return new picka().render(a, b);
  }

  @Override
  protected void doLayout() {
    beginDoLayout(sourceTemplate);
    ; // line 1, picka.html
    p("<p>\n" + "some text: "); // line 1, picka.html
    p(a); // line 3, picka.html
    p(" \n" + "</p>\n" + "<p>\n"); // line 3, picka.html
    if (body != null) {
      body.setBuffer(getOut());
      body.render(a + b);
      body.resetBuffer();
    } // line 6, picka.html
    p("</p>\n"); // line 6, picka.html
    String x = renderBody("xxx"); // line 8, picka.html
    p("["); // line 8, picka.html
    p(x); // line 9, picka.html
    p("]\n" + "<p>\n" + "more text: "); // line 9, picka.html
    p(b); // line 11, picka.html
    p("\n" + "</p>\n" + " "); // line 11, picka.html

    endDoLayout(sourceTemplate);
  }
}
コード例 #27
0
ファイル: ActionInvoker.java プロジェクト: branaway/play
  public static void invoke(Http.Request request, Http.Response response) {
    Monitor monitor = null;

    try {

      resolve(request, response);
      Method actionMethod = request.invokedMethod;

      // 1. Prepare request params
      Scope.Params.current().__mergeWith(request.routeArgs);

      // add parameters from the URI query string
      String encoding = Http.Request.current().encoding;
      Scope.Params.current()
          ._mergeWith(
              UrlEncodedParser.parseQueryString(
                  new ByteArrayInputStream(request.querystring.getBytes(encoding))));

      // 2. Easy debugging ...
      if (Play.mode == Play.Mode.DEV) {
        Class<Controller> cclass = Controller.class;
        cclass.getDeclaredField("params").set(null, Scope.Params.current());
        cclass.getDeclaredField("request").set(null, Http.Request.current());
        cclass.getDeclaredField("response").set(null, Http.Response.current());
        cclass.getDeclaredField("session").set(null, Scope.Session.current());
        cclass.getDeclaredField("flash").set(null, Scope.Flash.current());
        cclass.getDeclaredField("renderArgs").set(null, Scope.RenderArgs.current());
        cclass.getDeclaredField("routeArgs").set(null, Scope.RouteArgs.current());
        cclass.getDeclaredField("validation").set(null, Validation.current());
      }

      ControllerInstrumentation.stopActionCall();
      Play.pluginCollection.beforeActionInvocation(actionMethod);

      // Monitoring
      monitor = MonitorFactory.start(request.action + "()");

      // 3. Invoke the action
      try {
        // @Before
        handleBefores(request);

        // Action

        Result actionResult = null;
        String cacheKey = null;

        // Check the cache (only for GET or HEAD)
        if ((request.method.equals("GET") || request.method.equals("HEAD"))
            && actionMethod.isAnnotationPresent(CacheFor.class)) {
          cacheKey = actionMethod.getAnnotation(CacheFor.class).id();
          if ("".equals(cacheKey)) {
            cacheKey = "urlcache:" + request.url + request.querystring;
          }
          actionResult = (Result) play.cache.Cache.get(cacheKey);
        }

        if (actionResult == null) {
          ControllerInstrumentation.initActionCall();
          try {
            inferResult(invokeControllerMethod(actionMethod));
          } catch (Result result) {
            actionResult = result;
            // Cache it if needed
            if (cacheKey != null) {
              play.cache.Cache.set(
                  cacheKey, actionResult, actionMethod.getAnnotation(CacheFor.class).value());
            }
          } catch (InvocationTargetException ex) {
            // It's a Result ? (expected)
            if (ex.getTargetException() instanceof Result) {
              actionResult = (Result) ex.getTargetException();
              // Cache it if needed
              if (cacheKey != null) {
                play.cache.Cache.set(
                    cacheKey, actionResult, actionMethod.getAnnotation(CacheFor.class).value());
              }

            } else {
              // @Catch
              Object[] args = new Object[] {ex.getTargetException()};
              List<Method> catches =
                  Java.findAllAnnotatedMethods(Controller.getControllerClass(), Catch.class);
              ControllerInstrumentation.stopActionCall();
              for (Method mCatch : catches) {
                Class[] exceptions = mCatch.getAnnotation(Catch.class).value();
                if (exceptions.length == 0) {
                  exceptions = new Class[] {Exception.class};
                }
                for (Class exception : exceptions) {
                  if (exception.isInstance(args[0])) {
                    mCatch.setAccessible(true);
                    inferResult(invokeControllerMethod(mCatch, args));
                    break;
                  }
                }
              }

              throw ex;
            }
          }
        }

        // @After
        handleAfters(request);

        monitor.stop();
        monitor = null;

        // OK, re-throw the original action result
        if (actionResult != null) {
          throw actionResult;
        }

        throw new NoResult();

      } catch (IllegalAccessException ex) {
        throw ex;
      } catch (IllegalArgumentException ex) {
        throw ex;
      } catch (InvocationTargetException ex) {
        // It's a Result ? (expected)
        if (ex.getTargetException() instanceof Result) {
          throw (Result) ex.getTargetException();
        }
        // Re-throw the enclosed exception
        if (ex.getTargetException() instanceof PlayException) {
          throw (PlayException) ex.getTargetException();
        }
        StackTraceElement element =
            PlayException.getInterestingStackTraceElement(ex.getTargetException());
        if (element != null) {
          throw new JavaExecutionException(
              Play.classes.getApplicationClass(element.getClassName()),
              element.getLineNumber(),
              ex.getTargetException());
        }
        throw new JavaExecutionException(Http.Request.current().action, ex);
      }

    } catch (Result result) {

      Play.pluginCollection.onActionInvocationResult(result);

      // OK there is a result to apply
      // Save session & flash scope now

      Scope.Session.current().save();
      Scope.Flash.current().save();

      result.apply(request, response);

      Play.pluginCollection.afterActionInvocation();

      // @Finally
      handleFinallies(request, null);

    } catch (PlayException e) {
      handleFinallies(request, e);
      throw e;
    } catch (Throwable e) {
      handleFinallies(request, e);
      throw new UnexpectedException(e);
    } finally {
      Play.pluginCollection.onActionInvocationFinally();

      if (monitor != null) {
        monitor.stop();
      }
    }
  }