Class ViewContextTool

  • All Implemented Interfaces:
    java.io.Serializable

    public class ViewContextTool
    extends org.apache.velocity.tools.generic.ContextTool

    Extension of ContextTool that includes keys and values from the HttpServletRequest, HttpSession and ServletContext.

    Template example(s):

      #foreach( $key in $context.keys )
        $key = $context.get($key)
      #end
     

    Toolbox configuration:

     <tools>
       <toolbox scope="request">
         <tool class="org.apache.velocity.tools.view.ViewContextTool"/>
       </toolbox>
     </tools>
     

    This class is only designed for use as a request-scope VelocityView tool.

    Since:
    VelocityTools 2.0
    Version:
    $Id: ViewContextTool.java 385122 2006-03-11 18:37:42Z nbubna $
    Author:
    Nathan Bubna
    See Also:
    Serialized Form
    • Field Summary

      Fields 
      Modifier and Type Field Description
      protected javax.servlet.ServletContext application  
      protected javax.servlet.http.HttpServletRequest request  
      protected javax.servlet.http.HttpSession session  
      • Fields inherited from class org.apache.velocity.tools.generic.ContextTool

        context, toolbox
      • Fields inherited from class org.apache.velocity.tools.generic.SafeConfig

        LOCK_CONFIG_KEY, log, LOGGER_NAME_KEY, SAFE_MODE_KEY, USE_CLASS_LOGGER_KEY
    • Constructor Summary

      Constructors 
      Constructor Description
      ViewContextTool()  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void configure​(org.apache.velocity.tools.generic.ValueParser parser)  
      protected void fillKeyset​(java.util.Set keys)  
      • Methods inherited from class org.apache.velocity.tools.generic.ContextTool

        contains, get, getKeys, getThis, getToolbox, getValues
      • Methods inherited from class org.apache.velocity.tools.generic.SafeConfig

        configure, getLog, initLogger, isConfigLocked, isSafeMode, setLockConfig, setSafeMode
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • request

        protected javax.servlet.http.HttpServletRequest request
      • session

        protected javax.servlet.http.HttpSession session
      • application

        protected javax.servlet.ServletContext application
    • Constructor Detail

      • ViewContextTool

        public ViewContextTool()
    • Method Detail

      • configure

        protected void configure​(org.apache.velocity.tools.generic.ValueParser parser)
        Overrides:
        configure in class org.apache.velocity.tools.generic.ContextTool
      • fillKeyset

        protected void fillKeyset​(java.util.Set keys)
        Overrides:
        fillKeyset in class org.apache.velocity.tools.generic.ContextTool