| Home >> All >> org >> apache >> [ velocity Javadoc ] |
Page 1 2
org.apache.velocity: Javadoc index of package org.apache.velocity.
Package Samples:
org.apache.velocity.demo.action
org.apache.velocity.demo.om
org.apache.velocity.demo
org.apache.velocity.anakia
org.apache.velocity.app.event
org.apache.velocity.app.tools
org.apache.velocity.app
org.apache.velocity.context
org.apache.velocity.convert
org.apache.velocity.exception
org.apache.velocity.io
org.apache.velocity.runtime.compiler
org.apache.velocity.runtime.configuration
org.apache.velocity.runtime.directive
org.apache.velocity.runtime.exception
org.apache.velocity.runtime.log
org.apache.velocity.runtime.parser.node
org.apache.velocity.runtime.parser
org.apache.velocity.runtime.resource.loader
org.apache.velocity.runtime.resource
Classes:
AbstractSearchTool: Abstract view tool for doing "searching" and robust pagination of search results. The goal here is to provide a simple and uniform API for "search tools" that can be used in velocity templates (or even a standard Search.vm template). In particular, this class provides good support for result pagination and some very simple result caching. Usage: To use this class, you must extend it and implement the setup(HttpServletRequest) and executeQuery(Object) methods. The setup(HttpServletRequest) method ought to extract from the current request the search criteria, the current list index, and optionally, ...
VelocityViewServlet: A servlet to process Velocity templates. This is comparable to the the JspServlet for JSP-based applications. The servlet provides the following features: renders Velocity templates provides support for an auto-loaded, configurable toolbox provides transparent access to the servlet request attributes, servlet session attributes and servlet context attributes by auto-searching them logs to the logging facility of the servlet API VelocityViewServlet supports the following configuration parameters in web.xml: org.apache.velocity.toolbox Path and name of the toolbox configuration file. The path must ...
Configuration: This class extends normal Java properties by adding the possibility to use the same key many times concatenating the value strings instead of overwriting them. The Extended Properties syntax is explained here: Each property has the syntax key = value The key may use any character but the equal sign '='. value may be separated on different lines if a backslash is placed at the end of the line that continues below. If value is a list of strings, each token is separated by a comma ','. Commas in each token are escaped placing a backslash right before the comma. If a key is used more than once, the ...
AbstractPagerTool: Abstract view tool for doing request-based pagination of items in an a list. Usage: To use this class, you must extend it and implement the setup(HttpServletRequest) method. The setup(HttpServletRequest) method ought to extract from the current request the current list index and, optionally, the number of items to display per page. Upon extracting these parameters, they should be set using the provided setIndex(int) and setItemsPerPage(int) methods. A simple implementation would be: public void setup(HttpServletRequest req) { ParameterParser pp = new ParameterParser(req); setIndex(pp.getInt("index", ...
DataSourceResourceLoader: This is a simple template file loader that loads templates from a DataSource instead of plain files. It can be configured with a datasource name, a table name, id column (name), content column (the template body) and a datetime column (for last modification info). Example configuration snippet for velocity.properties: resource.loader = file, ds ds.resource.loader.public.name = DataSource ds.resource.loader.description = Velocity DataSource Resource Loader ds.resource.loader.class = org.apache.velocity.runtime.resource.loader.DataSourceResourceLoader ds.resource.loader.resource.datasource = java:comp/env/jdbc/Velocity ...
SortTool: SortTool allows a user to sort a collection (or array, iterator, etc) on any arbitary set of properties exposed by the objects contained within the collection. The sort tool is specifically designed to use within a #foreach but you may find other uses for it. The sort tool can handle all of the collection types supported by #foreach and the same constraints apply as well as the following. Every object in the collection must support the set of properties selected to sort on. Each property which is to be sorted on must return one of the follow: Primitive type: e.g. int, char, long etc Standard Object: ...
VMProxyArg: The function of this class is to proxy for the calling parameter to the VM. This class is designed to be used in conjunction with the VMContext class which knows how to get and set values via it, rather than a simple get() or put() from a hashtable-like object. There is probably a lot of undocumented subtlty here, so step lightly. We rely on the observation that an instance of this object has a constant state throughout its lifetime as it's bound to the use-instance of a VM. In other words, it's created by the VelocimacroProxy class, to represent one of the arguments to a VM in a specific template. ...
ServletToolboxManager: A toolbox manager for the servlet environment. A toolbox manager is responsible for automatically filling the Velocity context with a set of view tools. This class provides the following features: configurable through an XML-based configuration file assembles a set of view tools (the toolbox) on request handles different tool scopes (request, session, application) supports any class with a public constructor without parameters to be used as a view tool supports adding primitive data values to the context(String,Number,Boolean) Configuration The toolbox manager is configured through an XML-based ...
EscapeTool: Tool for working with escaping in Velocity templates. It provides methods to escape outputs for Java, JavaScript, HTML, XML and SQL. Also provides methods to render VTL characters that otherwise needs escaping. Example uses: $java -> He didn't say, "Stop!" $esc.java($java) -> He didn't say, \"Stop!\" $javascript -> He didn't say, "Stop!" $esc.javascript($javascript) -> He didn\'t say, \"Stop!\" $html -> "bread" & "butter" $esc.html($html) -> "bread" & "butter" $xml -> "bread" & "butter" $esc.xml($xml) -> "bread" & "butter" ...
DateTool: Tool for working with java.util.Date and java.util.Calendar in Velocity templates. It is useful for accessing and formatting the "current" date as well as for formatting arbitrary java.util.Date and java.util.Calendar objects. Also the tool can be used to retrieve java.text.DateFormat instances or make conversions to and from various date types. Example uses: $date -> Oct 19, 2003 9:54:50 PM $date.long -> October 19, 2003 9:54:50 PM PDT $date.medium_time -> 9:54:50 PM $date.full_date -> Sunday, October 19, 2003 $date.get('default','short') -> Oct 19, 2003 9:54 PM $date.get('yyyy-M-d H:m:s') -> ...
BrowserSnifferTool: browser-sniffing tool (session or request scope requested, session scope advised). Usage: BrowserSniffer defines properties that are used to test the client browser, operating system, device... Apart from properties related to versioning, all properties are booleans. The following properties are available: Versioning: version majorVersion minorVersion geckoVersion Browser: mosaic netscape nav2 nav3 nav4 nav4up nav45 nav45up nav6 nav6up navgold firefox safari ie ie3 ie4 ie4up ie5 ie5up ie55 ie55up ie6 opera opera3 opera4 opera5 opera6 opera7 lynx links aol aol3 aol4 aol5 aol6 neoplanet neoplanet2 ...
RuntimeSingleton: This is the Runtime system for Velocity. It is the single access point for all functionality in Velocity. It adheres to the mediator pattern and is the only structure that developers need to be familiar with in order to get Velocity to perform. The Runtime will also cooperate with external systems like Turbine. Runtime properties can set and then the Runtime is initialized. Turbine for example knows where the templates are to be loaded from, and where the velocity log file should be placed. So in the case of Velocity cooperating with Turbine the code might look something like the following: RuntimeSingleton.setProperty(RuntimeConstants.FILE_RESOURCE_LOADER_PATH, ...
RuntimeInstance: This is the Runtime system for Velocity. It is the single access point for all functionality in Velocity. It adheres to the mediator pattern and is the only structure that developers need to be familiar with in order to get Velocity to perform. The Runtime will also cooperate with external systems like Turbine. Runtime properties can set and then the Runtime is initialized. Turbine, for example, knows where the templates are to be loaded from, and where the Velocity log file should be placed. So in the case of Velocity cooperating with Turbine the code might look something like the following: ri.setProperty(Runtime.FILE_RESOURCE_LOADER_PATH, ...
Runtime: This is the Runtime system for Velocity. It is the single access point for all functionality in Velocity. It adheres to the mediator pattern and is the only structure that developers need to be familiar with in order to get Velocity to perform. The Runtime will also cooperate with external systems like Turbine. Runtime properties can set and then the Runtime is initialized. Turbine for example knows where the templates are to be loaded from, and where the velocity log file should be placed. So in the case of Velocity cooperating with Turbine the code might look something like the following: Runtime.setProperty(Runtime.FILE_RESOURCE_LOADER_PATH, ...
InternalContextAdapterImpl: This adapter class is the container for all context types for internal use. The AST now uses this class rather than the app-level Context interface to allow flexibility in the future. Currently, we have two context interfaces which must be supported : Context : used for application/template data access InternalHousekeepingContext : used for internal housekeeping and caching InternalWrapperContext : used for getting root cache context and other such. InternalEventContext : for event handling. This class implements the two interfaces to ensure that all methods are supported. When adding to the interfaces, ...
XMLToolboxManager: A ToolboxManager for loading a toolbox from xml. A toolbox manager is responsible for automatically filling the Velocity context with a set of view tools. This class provides the following features: configurable through an XML-based configuration file assembles a set of view tools (the toolbox) on request supports any class with a public constructor without parameters to be used as a view tool supports adding primitive data values to the context(String,Number,Boolean) Configuration The toolbox manager is configured through an XML-based configuration file. The configuration file is passed to the ...
ClasspathResourceLoader: ClasspathResourceLoader is a simple loader that will load templates from the classpath. Will load templates from from multiple instances of and arbitrary combinations of : jar files zip files template directories (any directory containing templates) This is a configuration-free loader, in that there are no parameters to be specified in the configuration properties, other than specifying this as the loader to use. For example the following is all that the loader needs to be functional : resource.loader = class class.resource.loader.class = org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader ...
ChainedContext: Velocity context implementation specific to the Servlet environment. It provides the following special features: puts the request, response, session, and servlet context objects into the Velocity context for direct access, and keeps them read-only supports a read-only toolbox of view tools auto-searches servlet request attributes, session attributes and servlet context attribues for objects The internalGet(String key) 55 method implements the following search order for objects: toolbox servlet request, servlet response, servlet session, servlet context local hashtable of objects (traditional use) ...
VelocityServlet: Base class which simplifies the use of Velocity with Servlets. Extend this class, implement the handleRequest() method, and add your data to the context. Then call getTemplate("myTemplate.wm") . This class puts some things into the context object that you should be aware of: "req" - The HttpServletRequest object "res" - The HttpServletResponse object There are other methods you can override to access, alter or control any part of the request processing chain. Please see the javadocs for more information on : loadConfiguration() : for setting up the Velocity runtime createContext() : for creating ...
FieldMethodizer: This is a small utility class allow easy access to static fields in a class, such as string constants. Velocity will not introspect for class fields (and won't in the future :), but writing setter/getter methods to do this really is a pain, so use this if you really have to access fields. The idea it so enable access to the fields just like you would in Java. For example, in Java, you would access a static field like MyClass.STRING_CONSTANT and that is the same thing we are trying to allow here. So to use in your Java code, do something like this : context.put("runtime", new FieldMethodizer( "org.apache.velocity.runtime.Runtime" ...
Include: Pluggable directive that handles the #include() statement in VTL. This #include() can take multiple arguments of either StringLiteral or Reference. Notes: ----- 1) The included source material can only come from somewhere in the TemplateRoot tree for security reasons. There is no way around this. If you want to include content from elsewhere on your disk, use a link from somwhere under Template Root to that content. 2) By default, there is no output to the render stream in the event of a problem. You can override this behavior with two property values : include.output.errormsg.start include.output.errormsg.end ...
ViewRenderTool: This tool expose methods to evaluate the given strings as VTL (Velocity Template Language) and automatically using the current context. Example of eval(): Input ----- #set( $list = [1,2,3] ) #set( $object = '$list' ) #set( $method = 'size()' ) $render.eval("${object}.$method") Output ------ 3 Example of recurse(): Input ----- #macro( say_hi )hello world!#end #set( $foo = '#say_hi()' ) #set( $bar = '$foo' ) $render.recurse('$bar') Output ------ hello world! Toolbox configuration: <tool> <key>render</key> <scope>request</scope> <class>org.apache.velocity.tools.view.tools.ViewRenderTool</class> ...
XPathTool: This class adds an entrypoint into XPath functionality, for Anakia. All methods take a string XPath specification, along with a context, and produces a resulting java.util.List. The W3C XPath Specification (http://www.w3.org/TR/xpath) refers to NodeSets repeatedly, but this implementation simply uses java.util.List to hold all Nodes. A 'Node' is any object in a JDOM object tree, such as an org.jdom.Element, org.jdom.Document, or org.jdom.Attribute. To use it in Velocity, do this: #set $authors = $xpath.applyTo("document/author", $root) #foreach ($author in $authors) $author.getValue() #end #set ...
NumberTool: Tool for working with java.lang.Number in Velocity templates. It is useful for accessing and formatting arbitrary java.lang.Number objects. Also the tool can be used to retrieve java.text.NumberFormat instances or make conversions to and from various number types. Example uses: $myNumber -> 13.55 $number.format('currency',$myNumber) -> $13.55 $number.format('integer',$myNumber) -> 13 Example toolbox.xml config (if you want to use this with VelocityView): <tool> <key>number</key> <scope>application</scope> <class>org.apache.velocity.tools.generic.NumberTool</class> ...
RenderTool: This tool exposes methods to evaluate the given strings as VTL (Velocity Template Language) using the given context. NOTE: These examples assume you have placed an instance of the current context within itself as 'ctx'. And, of course, the RenderTool is assumed to be available as 'render'. Example of eval(): Input ----- #set( $list = [1,2,3] ) #set( $object = '$list' ) #set( $method = 'size()' ) $render.eval($ctx, "${object}.$method") Output ------ 3 Example of recurse(): Input ----- #macro( say_hi )hello world!#end #set( $foo = '#say_hi()' ) #set( $bar = '$foo' ) $render.recurse($ctx, $bar) Output ...
| Home | Contact Us | Privacy Policy | Terms of Service |