Class VelocityViewsRenderer<T,R>

java.lang.Object
io.micronaut.views.velocity.VelocityViewsRenderer<T,R>
Type Parameters:
T - The model type
R - The request type
All Implemented Interfaces:
io.micronaut.core.order.Ordered, ViewsRenderer<T,R>

@Singleton public class VelocityViewsRenderer<T,R> extends Object implements ViewsRenderer<T,R>
Renders with templates with Apache Velocity Project.
Since:
1.0
Author:
Sergio del Amo, graemerocher
See Also:
  • Field Details

    • velocityEngine

      protected final org.apache.velocity.app.VelocityEngine velocityEngine
    • viewsConfiguration

      protected final ViewsConfiguration viewsConfiguration
    • velocityConfiguration

      protected final VelocityViewsRendererConfiguration velocityConfiguration
    • folder

      protected final String folder
  • Constructor Details

    • VelocityViewsRenderer

      @Inject public VelocityViewsRenderer(ViewsConfiguration viewsConfiguration, VelocityViewsRendererConfiguration velocityConfiguration, org.apache.velocity.app.VelocityEngine velocityEngine)
      Parameters:
      viewsConfiguration - Views Configuration
      velocityConfiguration - Velocity Configuration
      velocityEngine - Velocity Engine
  • Method Details

    • render

      @NonNull public @NonNull io.micronaut.core.io.Writable render(@NonNull @NonNull String view, @Nullable T data, @NonNull R request)
      Specified by:
      render in interface ViewsRenderer<T,R>
      Parameters:
      view - view name to be rendered
      data - response body to render it with a view
      request - HTTP request
      Returns:
      A writable where the view will be written to.
    • render

      public void render(@NonNull @NonNull String view, org.apache.velocity.VelocityContext context, String encoding, Writer writer)
      Parameters:
      view - The view
      context - The context
      encoding - The encoding
      writer - The writer
    • exists

      public boolean exists(@NonNull @NonNull String viewName)
      Specified by:
      exists in interface ViewsRenderer<T,R>
      Parameters:
      viewName - view name to be rendered
      Returns:
      true if a template can be found for the supplied view name.