Class VelocityViewsRenderer<T,R>

java.lang.Object
io.micronaut.views.AbstractViewsRenderer<T,R>
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 AbstractViewsRenderer<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
  • 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

      public @NonNull io.micronaut.core.io.Writable render(@NonNull String view, @Nullable T data, @NonNull R request)
      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 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 String viewName)
      Description copied from class: AbstractViewsRenderer
      Determines whether a template resource for the given view name is available.

      Returns false when this renderer was created without a resource loader.

      Specified by:
      exists in interface ViewsRenderer<T,R>
      Overrides:
      exists in class AbstractViewsRenderer<T,R>
      Parameters:
      viewName - The requested view name, with or without the configured extension
      Returns:
      Whether the corresponding template resource exists