Class AbstractVelocityJsComponent

java.lang.Object
com.vaadin.flow.component.Component
org.vaadin.addons.velocitycomponent.AbstractVelocityJsComponent
All Implemented Interfaces:
com.vaadin.flow.component.AttachNotifier, com.vaadin.flow.component.DetachNotifier, com.vaadin.flow.component.HasElement, com.vaadin.flow.component.HasStyle, Serializable

public abstract class AbstractVelocityJsComponent extends com.vaadin.flow.component.Component
This is a base class for components that use Velocity to generate JavaScript for their front-end integration.

The component can use the velocityJs(String, VelocityContext, List) method or its overloads to execute JavaScript in the context of the components base element. The passed JavaScript is first processed using Velocity templating engine, so you can use named parameters from the context. The context by default contains the component itself (referred as $this) and the Json helper class (referred as $Json).

See Also:
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.apache.velocity.VelocityContext
    Get the VelocityContext for this component.
    protected com.vaadin.flow.component.page.PendingJavaScriptResult
    velocityJs(String jsVelocityTemplate)
     
    protected com.vaadin.flow.component.page.PendingJavaScriptResult
    velocityJs(String jsVelocityTemplate, Map<String,Object> additionalContext)
     
    protected com.vaadin.flow.component.page.PendingJavaScriptResult
    velocityJs(String jsVelocityTemplate, org.apache.velocity.VelocityContext ctx, List<com.vaadin.flow.dom.Element> specialParameters)
     

    Methods inherited from class com.vaadin.flow.component.Component

    addListener, findAncestor, fireEvent, from, get, getChildren, getElement, getEventBus, getId, getListeners, getLocale, getParent, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getTranslation, getUI, hasListener, isAttached, isTemplateMapped, isVisible, onAttach, onDetach, onEnabledStateChanged, removeFromParent, scrollIntoView, scrollIntoView, set, setElement, setId, setVisible

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface com.vaadin.flow.component.AttachNotifier

    addAttachListener

    Methods inherited from interface com.vaadin.flow.component.DetachNotifier

    addDetachListener

    Methods inherited from interface com.vaadin.flow.component.HasStyle

    addClassName, addClassNames, getClassName, getClassNames, getStyle, hasClassName, removeClassName, removeClassNames, setClassName, setClassName
  • Constructor Details

    • AbstractVelocityJsComponent

      public AbstractVelocityJsComponent()
  • Method Details

    • getVelocityContext

      protected org.apache.velocity.VelocityContext getVelocityContext()
      Get the VelocityContext for this component.

      The component can override to add more context or to cache the context.

      Returns:
      the VelocityContext used to execute JS with special methods.
    • velocityJs

      protected com.vaadin.flow.component.page.PendingJavaScriptResult velocityJs(String jsVelocityTemplate)
    • velocityJs

      protected com.vaadin.flow.component.page.PendingJavaScriptResult velocityJs(String jsVelocityTemplate, org.apache.velocity.VelocityContext ctx, List<com.vaadin.flow.dom.Element> specialParameters)
    • velocityJs

      protected com.vaadin.flow.component.page.PendingJavaScriptResult velocityJs(String jsVelocityTemplate, Map<String,Object> additionalContext)