org.apache.wicket.velocity
Class VelocityContributor

java.lang.Object
  extended by org.apache.wicket.behavior.AbstractBehavior
      extended by org.apache.wicket.velocity.VelocityContributor
All Implemented Interfaces:
Serializable, IBehavior, IComponentConfigurationBehavior, IClusterable, IHeaderContributor
Direct Known Subclasses:
VelocityJavascriptContributor

public class VelocityContributor
extends AbstractBehavior
implements IHeaderContributor

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(String templateName, IModel<? extends 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  CharSequence evaluate()
          Evaluate the template.
 String getEncoding()
           
 void renderHead(IHeaderResponse response)
          Render to the web response whatever the component wants to contribute to the head section.
 void setEncoding(String encoding)
           
 
Methods inherited from class org.apache.wicket.behavior.AbstractBehavior
afterRender, beforeRender, bind, cleanup, detachModel, exception, getStatelessHint, isEnabled, isTemporary, onComponentTag, onConfigure, onException, onRendered, rendered
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

VelocityContributor

public VelocityContributor(String templateName,
                           IModel<? extends 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)
Description copied from interface: IBehavior
Allows the behavior to detach any state it has attached during request processing.

Specified by:
detach in interface IBehavior
Overrides:
detach in class AbstractBehavior
Parameters:
c - the component that initiates the detachment of this behavior
See Also:
AbstractBehavior.detach(org.apache.wicket.Component)

getEncoding

public String getEncoding()
Returns:
The encoding

renderHead

public void renderHead(IHeaderResponse response)
Description copied from interface: IHeaderContributor
Render to the web response whatever the component wants to contribute to the head section. TODO: Post 1.3, add component parameter, so that the behaviors dont' have to track component instances

Specified by:
renderHead in interface IHeaderContributor
Overrides:
renderHead in class AbstractBehavior
Parameters:
response - Response object
See Also:
AbstractBehavior.renderHead(org.apache.wicket.markup.html.IHeaderResponse)

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


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