/** * Render the template corresponding to the action's package-class-method name (@see <code>template()</code>). * * @param args * The template data. */ protected static void renderTemplate(Map<String, Object> args) { renderTemplate(template(), args); }
/** * Render a specific template * * @param templateName * The template name * @param args * The template data */ protected static void renderTemplate(String templateName, Object... args) { // Template datas Map<String, Object> templateBinding = new HashMap<>(16); for (Object o : args) { List<String> names = LocalVariablesNamesTracer.getAllLocalVariableNames(o); for (String name : names) { templateBinding.put(name, o); } } renderTemplate(templateName, templateBinding); }
/** * Render the corresponding template (@see <code>template()</code>). * * @param args * The template data */ protected static void render(Object... args) { String templateName = null; if (args.length > 0 && args[0] instanceof String && LocalVariablesNamesTracer.getAllLocalVariableNames(args[0]).isEmpty()) { templateName = args[0].toString(); } else { templateName = template(); } renderTemplate(templateName, args); }
@SuppressWarnings("unchecked") public static void inferResult(Object o) { // Return type inference if (o != null) { if (o instanceof NoResult) { return; } if (o instanceof Result) { // Of course throw (Result) o; } if (o instanceof InputStream) { Controller.renderBinary((InputStream) o); } if (o instanceof File) { Controller.renderBinary((File) o); } if (o instanceof Map) { Controller.renderTemplate((Map<String, Object>) o); } if (o instanceof Object[]) { Controller.render(o); } Controller.renderHtml(o); } }