File: view.tag.xml

package info (click to toggle)
velocity-tools 2.0-9
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 3,952 kB
  • sloc: java: 24,414; xml: 7,944; jsp: 459; makefile: 24
file content (108 lines) | stat: -rw-r--r-- 3,904 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?xml version="1.0"?>

<!--
 Licensed to the Apache Software Foundation (ASF) under one
 or more contributor license agreements.  See the NOTICE file
 distributed with this work for additional information
 regarding copyright ownership.  The ASF licenses this file
 to you under the Apache License, Version 2.0 (the
 "License"); you may not use this file except in compliance
 with the License.  You may obtain a copy of the License at

   http://www.apache.org/licenses/LICENSE-2.0

 Unless required by applicable law or agreed to in writing,
 software distributed under the License is distributed on an
 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 KIND, either express or implied.  See the License for the
 specific language governing permissions and limitations
 under the License.
-->

<document>
    <properties>
        <title>VelocityViewTag</title>
        <projectfile>xdocs/project.xml</projectfile>
        <subprojectfile>xdocs/view.project.xml</subprojectfile>
    </properties>
    <body>
        <section name="Overview">
            <p class="note">
            This page is still unfinished. For details on configuring
            the VelocityViewTag, you can follow most of the instructions
            for the <a href="view.servlet.html">VelocityViewServlet</a>
            and of course on the <a href="config.html">configuration pages</a>.
            <a href="index.html#Contribution">Help finishing this is welcome!</a>
            </p>
            <p>
            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:
            </p>
        <sourcecode>
Hello $!bodyContent World!
        </sourcecode>
            <p>
            This tag can process that template by doing:
            </p>
        <sourcecode>
&lt;%@taglib prefix="velocity" uri="http://velocity.apache.org/velocity-view" %&gt;

&lt;velocity:view template="foo.vm"/&gt;
        </sourcecode>
            <p>
             VTL in the body of the tag:
            </p>
        <sourcecode>
&lt;%@taglib prefix="velocity" uri="http://velocity.apache.org/velocity-view" %&gt;

&lt;velocity:view&gt;
#if( $date.E eq 'Friday' )
 Happy
#else
 Sad
#end
&lt;/velocity:view&gt;
        </sourcecode>
            <p>
            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:
            </p>
        <sourcecode>
&lt;%@taglib prefix="velocity" uri="http://velocity.apache.org/velocity-view" %&gt;

&lt;velocity:view template="foo.vm"&gt;
#if( $date.E eq 'Friday' )
 Happy
#else
 Sad
#end
&lt;/velocity:view&gt;
        </sourcecode>
            <p>
            You can also store the results of any of the options above into
            a variable of any name and scope (default scope is "page"):
            </p>
        <sourcecode>
&lt;%@taglib prefix="velocity" uri="http://velocity.apache.org/velocity-view" %&gt;

&lt;velocity:view var="foo" scope="request" template="foo.vm"&gt;
#if( $date.E eq 'Friday' )
 Happy
#else
 Sad
#end
&lt;/velocity:view&gt;
        </sourcecode>
            <p>
            For more details, see the
            <a href="javadoc/org/apache/velocity/tools/view/jsp/VelocityViewTag.html">Javadoc</a>
            or the
            <a href="http://svn.apache.org/repos/asf/velocity/tools/trunk/src/main/java/META-INF/velocity-view.tld">TLD</a>.
            </p>
        </section>
    </body>
</document>