org.apache.wicket.velocity
Class VelocityContributor

java.lang.Object
  extended by org.apache.wicket.behavior.Behavior
      extended by org.apache.wicket.velocity.VelocityContributor
All Implemented Interfaces:
java.io.Serializable, IClusterable, IComponentAwareEventSink, IComponentAwareHeaderContributor
Direct Known Subclasses:
VelocityJavaScriptContributor

public class VelocityContributor
extends 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
VelocityContributor(java.lang.String templateName, IModel<? extends java.util.Map<?,?>> model)
          The templateName needs to have the full path relative to where the resource loader starts looking.
 
Method Summary
 void detach(Component c)
          Allows the behavior to detach any state it has attached during request processing.
protected  boolean escapeHtml()
           
protected  java.lang.CharSequence evaluate()
          Evaluate the template.
 java.lang.String getEncoding()
           
 void renderHead(Component component, IHeaderResponse response)
          Render to the web response whatever the component wants to contribute to the head section.
 void setEncoding(java.lang.String encoding)
           
 
Methods inherited from class org.apache.wicket.behavior.Behavior
afterRender, beforeRender, bind, canCallListenerInterface, getStatelessHint, isEnabled, isTemporary, onComponentTag, onConfigure, onEvent, onException, unbind
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VelocityContributor

public VelocityContributor(java.lang.String templateName,
                           IModel<? extends java.util.Map<?,?>> 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(Component c)
Allows the behavior to detach any state it has attached during request processing.

Overrides:
detach in class Behavior
Parameters:
c - the component that initiates the detachment of this behavior

getEncoding

public java.lang.String getEncoding()
Returns:
The encoding

renderHead

public void renderHead(Component component,
                       IHeaderResponse response)
Render to the web response whatever the component wants to contribute to the head section.

Specified by:
renderHead in interface IComponentAwareHeaderContributor
Overrides:
renderHead in class Behavior
Parameters:
component - component which is contributing to the response. This parameter is here to give the component as the context for component-awares implementing this interface
response - Response object

setEncoding

public void setEncoding(java.lang.String encoding)
Parameters:
encoding - The encoding

escapeHtml

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

evaluate

protected final java.lang.CharSequence evaluate()
Evaluate the template.

Returns:
The evaluated template


Copyright © 2006-2011 Apache Software Foundation. All Rights Reserved.