Save This Page
Home » struts-2.0.11.2-src » org.apache » struts2 » dispatcher » [javadoc | source]
org.apache.struts2.dispatcher
public class: VelocityResult [javadoc | source]
java.lang.Object
   org.apache.struts2.dispatcher.StrutsResultSupport
      org.apache.struts2.dispatcher.VelocityResult

All Implemented Interfaces:
    com.opensymphony.xwork2.Result, StrutsStatics

Using the Servlet container's JspFactory , this result mocks a JSP execution environment and then displays a Velocity template that will be streamed directly to the servlet output.

This result type takes the following parameters:

This result follows the same rules from StrutsResultSupport .

Example:

<result name="success" type="velocity">
<param name="location">foo.vm</param>
</result>
Fields inherited from org.apache.struts2.dispatcher.StrutsResultSupport:
DEFAULT_PARAM
Constructor:
 public VelocityResult() 
 public VelocityResult(String location) 
Method from org.apache.struts2.dispatcher.VelocityResult Summary:
createContext,   doExecute,   getContentType,   getEncoding,   getTemplate,   setDefaultEncoding,   setVelocityManager
Methods from org.apache.struts2.dispatcher.StrutsResultSupport:
conditionalParse,   doExecute,   execute,   getLastFinalLocation,   setEncode,   setLocation,   setParse
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.apache.struts2.dispatcher.VelocityResult Detail:
 protected Context createContext(VelocityManager velocityManager,
    ValueStack stack,
    HttpServletRequest request,
    HttpServletResponse response,
    String location) 
    Creates the VelocityContext that we'll use to render this page.
 public  void doExecute(String finalLocation,
    ActionInvocation invocation) throws Exception 
    Creates a Velocity context from the action, loads a Velocity template and executes the template. Output is written to the servlet output stream.
 protected String getContentType(String templateLocation) 
    Retrieve the content type for this template.

    People can override this method if they want to provide specific content types for specific templates (eg text/xml).

 protected String getEncoding(String templateLocation) 
    Retrieve the encoding for this template.

    People can override this method if they want to provide specific encodings for specific templates.

 protected Template getTemplate(ValueStack stack,
    VelocityEngine velocity,
    ActionInvocation invocation,
    String location,
    String encoding) throws Exception 
    Given a value stack, a Velocity engine, and an action invocation, this method returns the appropriate Velocity template to render.
 public  void setDefaultEncoding(String val) 
 public  void setVelocityManager(VelocityManager mgr)