org.apache.velocity.tools.view.tools

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Template Engine » Velocity » org.apache.velocity.tools.view.tools 
org.apache.velocity.tools.view.tools

Provides the ViewTool and Configurable interfaces, as well as a number of useful implementing classes. These are tools specifically meant for use in a web application.

Package Specification

Related Documentation

Java Source File NameTypeComment
AbstractPagerTool.javaClass

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", 0));
 setItemsPerPage(pp.getInt("show", DEFAULT_ITEMS_PER_PAGE));
 }
 
You can also set the list of items to be paged at this point using the setItems(List) method, or you can always set the item list at another point (even from within the template).

Here's an example of how your subclass would be used in a template:

 #if( $pager.hasItems() )
 Showing $!pager.pageDescription<br>
 #set( $i = $pager.index )
 #foreach( $item in $pager.page )
 ${i}.
AbstractSearchTool.javaClass

Abstract view tool for doing "searching" and robust pagination of search results.

BrowserSnifferTool.javaClass

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 amaya icab avantgo emacs mozilla gecko webtv staroffice lotusnotes konqueror
  • Operating systems:win16 win3x win31 win95 win98 winnt windows win32 win2k winxp winme dotnet mac macosx mac68k macppc os2 unix sun sun4 sun5 suni86 irix irix5 irix6 hpux hpux9 hpux10 aix aix1 aix2 aix3 aix4 linux sco unixware mpras reliant dec sinix freebsd bsd vms x11 amiga
  • Devices:palm audrey iopener wap blackberry
  • Features:javascript css css1 css2 dom0 dom1 dom2
  • Special:robot (true if the page is requested by a robot, i.e.
Configurable.javaInterface Interface for tools that can be passed configuration parameters.
ContextTool.javaClass
CookieTool.javaClass
ImportTool.javaClass General-purpose text-importing view tool for templates.

Usage:
Just call $import.read("http://www.foo.com/bleh.jsp?sneh=bar") to insert the contents of the named resource into the template.

 Toolbox configuration:
 <tool>
 <key>import</key>
 <scope>request</scope>
 <class>org.apache.velocity.tools.view.tools.ImportTool</class>
 </tool>
 


author:
   Marino A.
LinkTool.javaClass
ParameterParser.javaClass

Utility class for easy parsing of ServletRequest parameters.

 Template example(s):
 $params.foo                ->  bar
 $params.getNumber('baz')   ->  12.6
 $params.getInt('baz')      ->  12
 $params.getNumbers('baz')  ->  [12.6]
 Toolbox configuration:
 <tool>
 <key>params</key>
 <scope>request</scope>
 <class>org.apache.velocity.tools.view.tools.ParameterParser</class>
 </tool>
 

When used as a view tool, this should only be used in the request scope.

ViewRenderTool.javaClass 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>
 <parameter name="parse.depth" value="10"/>
 </tool>
 

Ok, so these examples are really lame.

ViewResourceTool.javaClass

Tool for accessing ResourceBundles and formatting messages therein.

 Template example(s):
 $text.foo                      ->  bar
 $text.hello.world              ->  Hello World!
 #set( $otherText = $text.bundle('otherBundle') )
 $otherText.foo                 ->  woogie
 $otherText.bar                 ->  The args are {0} and {1}.
 $otherText.bar.insert(4)       ->  The args are 4 and {1}.
 $otherText.bar.insert(4,true)  ->  The args are 4 and true.
 Toolbox configuration example:
 <tool>
 <key>text</key>
 <class>org.apache.velocity.tools.view.tools.ViewResourceTool</class>
 <parameter name="bundles" value="resources,com.foo.moreResources"/>
 </tool>
 

This comes in very handy when internationalizing templates. Note that the default resource bundle baseName is "resources", and the default locale is the result of HttpServletRequest.getLocale(). The default bundle baseName can be overridden as shown above.

Also, be aware that very few performance considerations have been made in this initial version.

ViewTool.javaInterface Generic view tool interface to assist in tool management. This interface provides the ViewTool.init(Object initData) method as a hook for ToolboxManager implementations to pass data in to tools to initialize them.
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.