Modified: velocity/site/cms/trunk/content/tools/devel/upgrading.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/tools/devel/upgrading.mdtext?rev=1834409&r1=1834408&r2=1834409&view=diff ============================================================================== --- velocity/site/cms/trunk/content/tools/devel/upgrading.mdtext (original) +++ velocity/site/cms/trunk/content/tools/devel/upgrading.mdtext Tue Jun 26 10:02:24 2018 @@ -16,6 +16,7 @@ For custom objects refering directly to Default tools aren't loaded anymore in velocity-tools-view. To load them, you must enable default loading from your `WEB-INF/web.xml` file: + :::xml <context-param> <param-name>org.apache.velocity.tools.loadDefaults</param-name> <param-value>true</param-value> @@ -23,6 +24,7 @@ Default tools aren't loaded anymore in v or do the same for a specific servlet inside its `<servlet>` tag: + ::xml <init-param> <param-name>org.apache.velocity.tools.loadDefaults</param-name> <param-value>true</param-value> @@ -98,6 +100,7 @@ If you do need a configuration, you shou If you are largely happy with the default tools.xml configuration, but wish to override just a few parts, you can override them with your own file. Tool configurations are key-centric. If you just want to provide a different default format for the [DateTool](apidocs/org/apache/velocity/tools/generic/DateTool.html) and a second bundle for the ResourceTool, your tools.xml can be just: + ::xml <tools> <toolbox scope="application"> <tool key="date" format="MM/dd/yy"/>
Modified: velocity/site/cms/trunk/content/tools/devel/view-layoutservlet.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/tools/devel/view-layoutservlet.mdtext?rev=1834409&r1=1834408&r2=1834409&view=diff ============================================================================== --- velocity/site/cms/trunk/content/tools/devel/view-layoutservlet.mdtext (original) +++ velocity/site/cms/trunk/content/tools/devel/view-layoutservlet.mdtext Tue Jun 26 10:02:24 2018 @@ -14,6 +14,7 @@ Since this class is an extension of the Three settings can be added to velocity.properties to control the VLS, or the following default values will be used: + :::properties # Filepath for error template, # relative to web application root directory tools.view.servlet.error.template = Error.vm @@ -32,11 +33,12 @@ Three settings can be added to velocity. Now, in your layout templates, the only thing you really need is the screen content reference. So an acceptable layout template could be: - $screen_content - + :::velocity + $!screen_content ...but that would make this whole thing an idiotic waste of time. At the least, you'll probably want to do something along these lines: + ::html+velocity <html> <head> <title>$!page_title</title> @@ -54,15 +56,16 @@ VLS provides two ways to specify an alte 1. **Specify the layout in the request parameters** - Just add the query string "layout=MyOtherLayout.vm" to any request params and the VLS will find it and render your screen within that layout instead of the default layout. It don't matter how you get the layout param into the query data, only that it's there. +Just add the query string "layout=MyOtherLayout.vm" to any request params and the VLS will find it and render your screen within that layout instead of the default layout. It don't matter how you get the layout param into the query data, only that it's there. 2. **Specify the layout in the requested screen.** - In the requested screen, put a line like this: - - #set( $layout = "MyOtherLayout.vm" ) - - This will direct the VLS to use "MyOtherLayout.vm" instead of "Default.vm". *Setting the layout in this fashion will override any layout set by the request parameters.* +In the requested screen, put a line like this: + + :::velocity + #set( $layout = "MyOtherLayout.vm" ) + +This will direct the VLS to use "MyOtherLayout.vm" instead of "Default.vm". *Setting the layout in this fashion will override any layout set by the request parameters.* ## 'Navigations', 'Tiles', and How @@ -70,10 +73,12 @@ Those of you who are (or were) Turbine o First, create your "tile" as a separate template file like: + :::html <div id="footer">I made this!</div> For creativity's sake, we'll pretend this code is in a file named "Footer.vm" that is located in the root of my webapp like my other non-layout templates. + :::html+velocity <html> <head> <title>$!page_title</title> @@ -91,6 +96,7 @@ Easy, eh? Now, what if you have a lot of different "footer" files and you want your screen to decide which one will be used? No problem! Do something like this: + :::html+velocity <html> <head> <title>$!page_title</title> @@ -104,7 +110,7 @@ Now, what if you have a lot of different </body> </html> -and in your screen, just do `#set( $screen_footer = 'FooFooter.vm' ).\ +and in your screen, just do `#set( $screen_footer = 'FooFooter.vm' )`. Remember, your #parsed footer template will have access to the same velocity context as your layout, which gets the screen's context once the screen is done with it. This lets you set variables for the layout and footer to use from your screens. @@ -121,6 +127,7 @@ $stack_trace | captured output of $error In the event that a MethodInvocationException is behind the calling of error(), the root cause is extracted from it and dealt with as described above. But, since template reference behavior is partly at fault here, the VLS will also add the MethodInvocationException itself to the context as $invocation_exception. This allows you to discover the reference and method call that triggered the root cause. To get those, do something like this in your error template: + ::velocity #if( $invocation_exception ) oh joy! it's a MethodInvocationException! Modified: velocity/site/cms/trunk/content/tools/devel/view-servlet.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/tools/devel/view-servlet.mdtext?rev=1834409&r1=1834408&r2=1834409&view=diff ============================================================================== --- velocity/site/cms/trunk/content/tools/devel/view-servlet.mdtext (original) +++ velocity/site/cms/trunk/content/tools/devel/view-servlet.mdtext Tue Jun 26 10:02:24 2018 @@ -21,6 +21,7 @@ The servlet configuration (**web.xml**) **web.xml** + :::xml <!-- Define Velocity template handler --> <servlet> <servlet-name>velocity</servlet-name> @@ -54,11 +55,13 @@ The servlet configuration (**web.xml**) Please note that the `org.apache.velocity.toolbox` and `org.apache.velocity.properties` parameters can also be set as `<context-params>` at the application level as follow: + :::xml <context-param> <param-name>org.apache.velocity.toolbox</param-name> <param-value>/WEB-INF/tools.xml</param-value> </context-param> + ::xml <context-param> <param-name>org.apache.velocity.properties</param-name> <param-value>/WEB-INF/velocity.properties</param-value> @@ -76,6 +79,7 @@ The location of the configuration file m Please see the [Velocity User's Guide](/engine/devel/user-guide.html) for more information on Velocity configuration. + :::properties velocimacro.library = /WEB-INF/VM_global_library.vm velocimacro.permissions.allow.inline = true velocimacro.permissions.allow.inline.to.replace.global = false @@ -92,6 +96,7 @@ The Velocity Toolbox works the same way, **PipeWrench.java** + :::java public class PipeWrench { public String getSize() { return "Large Pipe Wrench!"; @@ -100,6 +105,7 @@ The Velocity Toolbox works the same way, **tools.xml** + :::xml <?xml version="1.0"?> <tools> <toolbox scope="application"> @@ -122,6 +128,7 @@ The scope that you set for your toolbox You can specify a restriction on the request URIs for which the tool will be available in the context using the "restrictTo" attribute of your tool configuration. It can be an exact request path (matching one page) or end with the `*` wildcard, meaning that incoming request paths need only start with the provided value for the tool to be available. For instance: + :::xml <tool restrictTo="/catalog/*" class="com.mycompany.tools.CatalogTool"/> @@ -137,6 +144,7 @@ These things happen immediately after a You can specify properties for your tools, toolboxes or all tools either as <property> tags or as attributes: + :::xml <tools foo="true"> <toolbox scope="application" someProperty="whatever"> <property key="bar">woogie</property> @@ -150,6 +158,7 @@ You can specify properties for your tool In addition to specifiying arbitrary Java classes as **tools** to be automatically available to your templates, the toolbox support also includes the ability to specify arbitrary strings, booleans, numbers, lists of those, and even BeanUtils-convertable types to be automatically available in your templates. The format is as follows: + :::xml <?xml version="1.0"?> <tools> <data type="number" key="version" value="1.1"/> Modified: velocity/site/cms/trunk/content/tools/devel/view-tag.mdtext URL: http://svn.apache.org/viewvc/velocity/site/cms/trunk/content/tools/devel/view-tag.mdtext?rev=1834409&r1=1834408&r2=1834409&view=diff ============================================================================== --- velocity/site/cms/trunk/content/tools/devel/view-tag.mdtext (original) +++ velocity/site/cms/trunk/content/tools/devel/view-tag.mdtext Tue Jun 26 10:02:24 2018 @@ -7,16 +7,19 @@ This page is still unfinished. For detai This is a JSP tag that allows you to use Velocity and VelocityTools from within a JSP page or tag. There are many ways to use this tag. This simplest is to have it process an external template using the current page context. Assuming you have a template called "foo.vm" that can be found by your resource loader(s) that looks like this: + :::velocity Hello $!bodyContent World! This tag can process that template by doing: + :::jsp <%@taglib prefix="velocity" uri="http://velocity.apache.org/velocity-view" %> <velocity:view template="foo.vm"/> VTL in the body of the tag: + :::jsp <%@taglib prefix="velocity" uri="http://velocity.apache.org/velocity-view" %> <velocity:view> @@ -29,6 +32,7 @@ VTL in the body of the tag: or combine both by first processing the body of the tag, then inserting the results of that into the context for the separate template as $bodyContent: + :::jsp <%@taglib prefix="velocity" uri="http://velocity.apache.org/velocity-view" %> <velocity:view template="foo.vm"> @@ -41,6 +45,7 @@ or combine both by first processing the You can also store the results of any of the options above into a variable of any name and scope (default scope is "page"): + :::jsp <%@taglib prefix="velocity" uri="http://velocity.apache.org/velocity-view" %> <velocity:view var="foo" scope="request" template="foo.vm"> @@ -51,4 +56,4 @@ You can also store the results of any of #end </velocity:view> -For more details, see the [Javadoc](apidocs/org/apache/velocity/tools/view/jsp/VelocityViewTag.html) or the [TLD](http://svn.apache.org/repos/asf/velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld). +For more details, see the [Javadoc](apidocs/org/apache/velocity/tools/view/jsp/VelocityViewTag.html) or the [TLD](http://svn.apache.org/repos/asf/velocity/tools/trunk/src/main/resources/META-INF/velocity-view.tld).