Class VelocityContributor

  • All Implemented Interfaces:
    Serializable, org.apache.wicket.IComponentAwareEventSink, org.apache.wicket.markup.html.IComponentAwareHeaderContributor, org.apache.wicket.util.io.IClusterable
    Direct Known Subclasses:
    VelocityJavaScriptContributor

    public class VelocityContributor
    extends org.apache.wicket.behavior.Behavior
    An IHeaderContributor implementation that renders a velocity template and writes it to the response. The template is loaded via Velocity's resource loading mechanism, as defined in your velocity.properties. If you do not have a velocity.properties for your app, it will default to a directory "templates" in the root of your app.
    See Also:
    Serialized Form
    • Constructor Detail

      • VelocityContributor

        public VelocityContributor​(String templateName,
                                   org.apache.wicket.model.IModel<? extends Map<String,​Object>> model)
        The templateName needs to have the full path relative to where the resource loader starts looking. For example, if there is a template next to this class in the package called foo.vm, and you have configured the ClassPathResourceLoader, template name will then be "wicket/contrib/util/resource/foo.vm". Wicket provides a nice utility Packages for this.
        Parameters:
        templateName -
        model -
    • Method Detail

      • detach

        public void detach​(org.apache.wicket.Component c)
        Overrides:
        detach in class org.apache.wicket.behavior.Behavior
      • renderHead

        public void renderHead​(org.apache.wicket.Component component,
                               org.apache.wicket.markup.head.IHeaderResponse response)
        Specified by:
        renderHead in interface org.apache.wicket.markup.html.IComponentAwareHeaderContributor
        Overrides:
        renderHead in class org.apache.wicket.behavior.Behavior
      • setEncoding

        public void setEncoding​(String encoding)
        Parameters:
        encoding - The encoding
      • escapeHtml

        protected boolean escapeHtml()
        Returns:
        whether to escape HTML characters. The default value is false
      • evaluate

        protected final CharSequence evaluate()
        Evaluate the template.
        Returns:
        The evaluated template