Class FreeMarkerInlineRenderUtils

java.lang.Object
org.kuali.rice.krad.uif.freemarker.FreeMarkerInlineRenderUtils

public class FreeMarkerInlineRenderUtils extends Object
Inline FreeMarker rendering utilities.
Author:
Kuali Rice Team (rice.collab@kuali.org)
  • Constructor Details

    • FreeMarkerInlineRenderUtils

      public FreeMarkerInlineRenderUtils()
  • Method Details

    • resolve

      public static <T> T resolve(freemarker.core.Environment env, String name)
      Resolve a FreeMarker environment variable as a Java object.
      Parameters:
      env - The FreeMarker environment.
      name - The name of the variable.
      Returns:
      The FreeMarker variable, resolved as a Java object.
      See Also:
    • resolve

      public static <T> T resolve(freemarker.core.Environment env, String name, Class<T> type)
      Resolve a FreeMarker environment variable as a Java object, with type enforcement.

      This method is the preferred means to resolve variables for inline rendering.

      Parameters:
      env - The FreeMarker environment.
      name - The name of the variable.
      type - The expected type of the variable.
      Returns:
      The FreeMarker variable, resolved as a Java object of the given type.
    • getBeansWrapper

      public static freemarker.ext.beans.BeansWrapper getBeansWrapper(freemarker.core.Environment env)
      Get the object wrapper from the FreeMarker environment, as a BeansWrapper.
      Parameters:
      env - The FreeMarker environment.
      Returns:
      The object wrapper from the FreeMarker environment, type-cast as BeansWrapper .
    • resolveModel

      public static freemarker.template.TemplateModel resolveModel(freemarker.core.Environment env, String name)
      Resovle a FreeMarker variable as a FreeMarker template model object.
      Parameters:
      env - The FreeMarker environment.
      name - The name of the variable.
      Returns:
      The FreeMarker variable, resolved as a FreeMarker template model object.
      See Also:
    • renderTemplate

      public static void renderTemplate(freemarker.core.Environment env, Component component, String body, boolean componentUpdate, boolean includeSrc, Map<String,freemarker.template.TemplateModel> tmplParms) throws freemarker.template.TemplateException, IOException
      Render a KRAD component template inline.

      This method originated as template.ftl, and supercedes the previous content of that template.

      Parameters:
      env - The FreeMarker environment.
      component - The component to render a template for.
      body - The nested body.
      componentUpdate - True if this is an update, false for full view.
      includeSrc - True to include the template source in the environment when rendering, false to skip inclusion.
      tmplParms - Additional parameters to pass to the template macro.
      Throws:
      freemarker.template.TemplateException - If FreeMarker rendering fails.
      IOException - If rendering is interrupted due to an I/O error.
    • renderTooltip

      public static void renderTooltip(Component component, Writer out) throws IOException
      Render a KRAD tooltip component.

      This method originated as template.ftl, and supercedes the previous content of that template.

      Parameters:
      component - The component to render a tooltip for.
      out - The output writer to render to, typically from Environment.getOut().
      Throws:
      IOException - If rendering is interrupted due to an I/O error.
    • renderScript

      public static void renderScript(String script, Component component, String role, Writer out) throws IOException
      Render a KRAD script component.

      This method originated as script.ftl, and supercedes the previous content of that template.

      Parameters:
      script - The script to render.
      component - The component the script is related to.
      out - The output writer to render to, typically from Environment.getOut().
      Throws:
      IOException - If rendering is interrupted due to an I/O error.
    • renderAttrBuild

      public static void renderAttrBuild(Component component, Writer out) throws IOException
      Render common attributes for a KRAD component.

      NOTICE: By KULRICE-10353 this method duplicates, but does not replace, krad/WEB-INF/ftl/lib/attrBuild.ftl. When updating this method, also update that template.

      Parameters:
      component - The component to open a render attributes for.
      out - The output writer to render to, typically from Environment.getOut().
      Throws:
      IOException - If rendering is interrupted due to an I/O error.
    • renderOpenDiv

      public static void renderOpenDiv(Component component, Writer out) throws IOException
      Render an open div tag for a component.

      NOTE: Inline rendering performance is improved by *not* passing continuations for nested body content, so the open div and close div methods are implemented separately. Always call renderCloseDiv(Writer) after rendering the <div> body related to this open tag.

      NOTICE: By KULRICE-10353 this method duplicates, but does not replace, krad/WEB-INF/ftp/lib/div.ftl. When updating this method, also update that template.

      Parameters:
      component - The component to render a wrapper div for.
      out - The output writer to render to, typically from Environment.getOut().
      Throws:
      IOException - If rendering is interrupted due to an I/O error.
    • renderCloseDiv

      public static void renderCloseDiv(Writer out) throws IOException
      Render a close div tag for a component.

      NOTE: Inline rendering performance is improved by *not* passing continuations for nested body content, so the open div and close div methods are implemented separately. Always call this method after rendering the <div> body related to and open tag rendered by renderOpenDiv(Component, Writer).

      NOTICE: By KULRICE-10353 this method duplicates, but does not replace, krad/WEB-INF/ftp/lib/div.ftl. When updating this method, also update that template.

      Parameters:
      out - The output writer to render to, typically from Environment.getOut().
      Throws:
      IOException - If rendering is interrupted due to an I/O error.
    • renderOpenGroupWrap

      public static void renderOpenGroupWrap(freemarker.core.Environment env, Group group) throws IOException, freemarker.template.TemplateException
      Render open tags wrapping a group component.

      NOTE: Inline rendering performance is improved by *not* passing continuations for nested body content, so the open and close methods are implemented separately. Always call renderCloseGroupWrap(Environment, Group) after rendering the body related to a call to renderOpenGroupWrap(Environment, Group).

      This method originated as groupWrap.ftl, and supercedes the previous content of that template.

      Parameters:
      env - The FreeMarker environment to use for rendering.
      group - The group to render open wrapper tags for.
      Throws:
      IOException - If rendering is interrupted due to an I/O error.
      freemarker.template.TemplateException - If FreeMarker rendering fails.
    • renderCloseGroupWrap

      public static void renderCloseGroupWrap(freemarker.core.Environment env, Group group) throws IOException, freemarker.template.TemplateException
      Render close tags wrapping a group component.

      NOTE: Inline rendering performance is improved by *not* passing continuations for nested body content, so the open and close methods are implemented separately. Always call renderCloseGroupWrap(Environment, Group) after rendering the body related to a call to renderOpenGroupWrap(Environment, Group).

      This method originated as groupWrap.ftl, and supercedes the previous content of that template.

      Parameters:
      env - The FreeMarker environment to use for rendering.
      group - The group to render open wrapper tags for.
      Throws:
      IOException - If rendering is interrupted due to an I/O error.
      freemarker.template.TemplateException - If FreeMarker rendering fails.
    • renderCollectionGroup

      public static void renderCollectionGroup(freemarker.core.Environment env, CollectionGroup group) throws IOException, freemarker.template.TemplateException
      Render a collection group inline.

      This method originated as collectionGroup.ftl, and supercedes the previous content of that template.

      Parameters:
      group - The collection group to render.
      Throws:
      IOException - If rendering is interrupted due to an I/O error.
      freemarker.template.TemplateException - If FreeMarker rendering fails.
    • renderStacked

      public static void renderStacked(freemarker.core.Environment env, List<? extends Component> items, StackedLayoutManager manager, CollectionGroup container) throws IOException, freemarker.template.TemplateException
      Render a stacked collection inline.

      This method originated as stacked.ftl, and supercedes the previous content of that template.

      Parameters:
      env - The FreeMarker environment
      items - List of items to render in a stacked layout
      manager - Layout manager for the container
      container - Container to render
      Throws:
      IOException - If rendering is interrupted due to an I/O error.
      freemarker.template.TemplateException - If FreeMarker rendering fails.