Package org.apache.wicket.velocity
Class VelocityContributor
- java.lang.Object
-
- org.apache.wicket.behavior.Behavior
-
- org.apache.wicket.velocity.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 Summary
Constructors Constructor Description 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.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddetach(org.apache.wicket.Component c)protected booleanescapeHtml()protected CharSequenceevaluate()Evaluate the template.StringgetEncoding()voidrenderHead(org.apache.wicket.Component component, org.apache.wicket.markup.head.IHeaderResponse response)voidsetEncoding(String encoding)
-
-
-
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 utilityPackagesfor this.- Parameters:
templateName-model-
-
-
Method Detail
-
detach
public void detach(org.apache.wicket.Component c)
- Overrides:
detachin classorg.apache.wicket.behavior.Behavior
-
getEncoding
public String getEncoding()
- Returns:
- The encoding
-
renderHead
public void renderHead(org.apache.wicket.Component component, org.apache.wicket.markup.head.IHeaderResponse response)
- Specified by:
renderHeadin interfaceorg.apache.wicket.markup.html.IComponentAwareHeaderContributor- Overrides:
renderHeadin classorg.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
-
-