Package cn.bran.japid.template

Examples of cn.bran.japid.template.RenderResult


   * @param args
   *            arguments
   */
  public static <T extends JapidTemplateBaseWithoutPlay> void render(Class<T> c, Object... args) {
    try {
      RenderResult rr = invokeRender(c, args);
      throw new JapidResult(rr);
    } catch (Exception e) {
      if (e instanceof JapidResult)
        throw (JapidResult) e;

View Full Code Here


      // assuming second
      ttl += "s";
    }

    String base = StackTraceUtils.getCaller();
    RenderResult rr = getFromCache(base, objects);
    if (rr == null) {
      rr = runner.run();
      cache(rr, ttl, base, objects);
    }
    // System.out.println("render show took ms: " + rr.getRenderTime());
View Full Code Here

   * downstream of the pipeline
   *
   * @param r
   */
  protected static void render(CacheableRunner r) {
    RenderResult rr = r.run();
    throw new JapidResult(rr);
  }
View Full Code Here

   * @param s
   */
  protected static void renderText(String s) {
    Map<String, String> headers = new HashMap<String, String>();
    headers.put("Content-Type", "text/plain; charset=utf-8");
    render(new RenderResult(headers, new StringBuilder(s), -1L));
  }
View Full Code Here

          throw new RuntimeException("Japid Emailer: could not find a Japid template with the name of: " + templateFileName);
        } else if (JapidTemplateBase.class.isAssignableFrom(tClass)) {
          try {
          JapidController.render(tClass, args);
        } catch (JapidResult jr) {
          RenderResult rr = jr.getRenderResult();
          bodyHtml = rr.getContent().toString();
        }
        } else {
          throw new RuntimeException("The found class is not a Japid template class: " + templateClassName);
        }
View Full Code Here

 
 
  public static void foo() {
    StringBuilder sb = new StringBuilder();
    sb.append("--------------foo() action invoked:Hello foo!");
    RenderResult rr = new RenderResult(null, sb, 0);
   
    throw new JapidResult(rr);
   
//    runWithCache(new ActionRunner() {
//      @Override
View Full Code Here

    for (int i = 0; i < 5; i++) {
      posts.add(p);
    }

    long t = System.currentTimeMillis();
    RenderResult r = new AllPost(null).render("抬头", posts);
    System.out.println(System.currentTimeMillis() - t);
    System.out.println(r.getContent().toString());
  }
View Full Code Here

public class ControllerUtilsTest {

  @Test
  public void testRender() {
    RenderResult render;
   
    render = (RenderResult) RenderInvokerUtils.render(new Foo(null), "hi", new Integer(12));
    assertNotNull(render);

    render = (RenderResult) RenderInvokerUtils.render(new Foo(null), "hi", 12);
View Full Code Here

  /**
   *
   */
  @Test
  public void testSingleNull() {
    RenderResult render;
    // if cast to Object, the null is treated as an argument.
    // Otherwise the varargs is set to null.
    render = (RenderResult) RenderInvokerUtils.render(new Foo2(null), (Object)null);
    assertNotNull(render);
  }
View Full Code Here

  /**
   *
   */
  @Test
  public void testEmptyArgs() {
    RenderResult render;
    render = (RenderResult) RenderInvokerUtils.render(new Bar(null));
    assertNotNull(render);
  }
View Full Code Here

TOP

Related Classes of cn.bran.japid.template.RenderResult

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.