Package cn.bran.japid.template

Examples of cn.bran.japid.template.RenderResult


  protected static void renderJson(Object o) {
    String json = new Gson().toJson(o);
    Map<String, String> headers = new HashMap<String, String>();
    headers.put("Content-Type", "application/json; charset=utf-8");
    render(new RenderResult(headers, new StringBuilder(json), -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 RenderResult run() {
    if (!shouldCache()) {
      return render();
    } else {
      // cache in work
      RenderResult rr = null;
      if (!readThru) {
        try {
          rr = RenderResultCache.get(keyString);
          if (rr != null)
            return rr;
View Full Code Here

      throw new RuntimeException("Cannot init the template class since it's an abstract class: " + c.getName());
    }
    try {
      // String methodName = "render";
      Constructor<T> ctor = c.getConstructor(StringBuilder.class);
      RenderResult rr = invokeRenderer(ctor, args);
      // RenderResult rr = (RenderResult) MethodUtils.invokeMethod(t,
      // methodName, args);
      return rr;
    } catch (NoSuchMethodException e) {
      throw new RuntimeException("Could not match the arguments with the template args.");
View Full Code Here

  public static <T extends JapidTemplateBaseWithoutPlay> RenderResult invokeRenderer(Constructor<T> ctor,
      Object... args) {
    try {
      StringBuilder sb = new StringBuilder(8000);
      T t = ctor.newInstance(sb);
      RenderResult rr = render(t, args);
      JapidFlags.logTimeLogs(t);
      return rr;
    } catch (InstantiationException e) {
      // e.printStackTrace();
      throw new RuntimeException("Could not instantiate the template object. Abstract?");
View Full Code Here

    try {
      // String methodName = "render";
      Constructor<T> ctor = c.getConstructor(StringBuilder.class);
      StringBuilder sb = new StringBuilder(8000);
      JapidTemplateBaseWithoutPlay t = ctor.newInstance(sb);
      RenderResult rr = renderWithNamedArgs(t, args);
      JapidFlags.logTimeLogs(t);
      return rr;
    } catch (NoSuchMethodException e) {
      throw new RuntimeException("Could not match the arguments with the template args.");
    } catch (InstantiationException e) {
View Full Code Here

  protected RenderResult render() {
    Map<String, String> threadData = JapidController.threadData.get();
    threadData.put(GlobalSettingsWithJapid.ACTION_METHOD, controllerClass.getName() + "." + actionName);
    JapidResult jr = runPlayAction();
    threadData.remove(GlobalSettingsWithJapid.ACTION_METHOD);
    RenderResult rr = jr.getRenderResult();
    return rr;
  }
View Full Code Here

   * @param args
   *            arguments
   */
  public static <T extends JapidTemplateBaseWithoutPlay> JapidResult render(Class<T> c, Object... args) {
    try {
      RenderResult rr = RenderInvokerUtils.invokeRender(c, args);
      JapidResult japidResult = new JapidResult(rr);
      postProcess(japidResult);
      return japidResult;
    } catch (Exception e) {
      throw new RuntimeException(e);
View Full Code Here

   * @param args the arguments
   * @return
   */
  public static JapidResult renderDynamic(String template, Object... args) {
    try {
      RenderResult rr = JapidRenderer.renderDynamic(template, args);
      return new JapidResult(rr);
    } catch (Throwable e) {
      return new JapidResult(JapidRenderer.handleException(e));
    }
  }
View Full Code Here

    }
  }
 
  public static JapidResult renderDynamicByKey(String key, Object... args) {
    try {
      RenderResult rr = JapidRenderer.renderDynamicByKey(key, args);
      return new JapidResult(rr);
    } catch (Throwable e) {
      return new JapidResult(JapidRenderer.handleException(e));
    }
  }
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.