File: link.vm

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 (114 lines) | stat: -rw-r--r-- 4,466 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
109
110
111
112
113
114
## 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.
#title( 'LinkTool' )
<p>
#set( $demo = $text.demo )
$demo.thisPage.insert("#doclink( 'LinkTool' false )"). This tool
is somewhat unusual in that every method that takes parameters will return a new
instance of the tool that is a copy of the one the method was called upon, with
the additional change specified by the method call.
</p>

#demoTableStart()

#set( $desc = "Returns a new ${esc.d}link with the addition of the specified anchor value." )
#demo1( 'link' 'anchor' 6 $desc )

#set( $desc = "Returns the anchor set for the ${esc.d}link" )
#if( $params.anchor )
  #set( $result = $link.anchor($params.anchor) )
#else
  #set( $result = $!link.anchor )
#end
#demoAlt( 'link' 'anchor' $result $desc )

#set( $desc = "Returns a new ${esc.d}link with the addition of the specified path value." )
#demo1( 'link' 'path' 6 $desc )

#set( $desc = "Returns a new ${esc.d}link with the addition of the specified relative value." )
#demo1( 'link' 'relative' 6 $desc )

#set( $desc = "Returns a new ${esc.d}link with the addition of the specified absolute value." )
#demo1( 'link' 'absolute' 6 $desc )

#set( $desc = "Returns the path currently set for this ${esc.d}link." )
#demoAlt( 'link' 'path' $link.path $desc )

#set( $desc = "Returns a new ${esc.d}link with the addition of the specified parameter." )
#demo2( 'link' 'param' 6 $desc )


#set( $desc = "Returns the query data set for this ${esc.d}link" )
#if( $params.param )
  #set( $result = $link.param($params.param).params )
#else
  #set( $result = $link.params )
#end
#demoAlt( 'link' 'params' $result $desc )


#set( $desc = "Returns the URI that addresses this web application. E.g. <code>http://myserver.net/myapp</code>. This string may not end with a ${esc.q}/${esc.q}." )
#demo( 'link' 'contextURL' $desc )

#set( $desc = "Returns the context path that addresses this web application, e.g. <code>/myapp</code>. This string starts with a ${esc.q}/${esc.q} but does not end with a ${esc.q}/${esc.q}." )
#demo( 'link' 'contextPath' $desc )

#set( $desc = "Retrieves the path for the current request regardless of whether this is a direct request or an include by the RequestDispatcher." )
#demo( 'link' 'requestPath' $desc )

#set( $desc = "Returns the full URI of this template without any query data. e.g. <code>http://myserver.net/myapp/stuff/View.vm</code>" )
#demo( 'link' 'baseRef' $desc )

#set( $desc = "This method returns a new self-referencing ${esc.d}link for the current request (e.g. <code>/myapp/stuff/View.vm</code>).  However, the behavior can be changed via toolbox configuration to use absolute URIs and/or add the current request parameters." )
#demo( 'link' 'self' $desc )

#set( $desc = "Performs URL encoding on the specified text." )
#demo1( 'link' 'encode' 6 $desc )

#demoCustom( 'link' )
</table>

#set( $base = $link.self.anchor('fullDemo') )

<div align="center">
  <a name="fullDemo"><h3>$demo.mainExampleHeader</h3></a>
<form method="post" action="$link.self.anchor('fullDemo')">
<textarea name="fullDemo" rows="5" cols="65">##
#if( $params.fullDemo )##
$params.fullDemo##
#else##
${esc.h}${esc.h} NOTE: this first line is done in the actual page,
${esc.h}${esc.h}       because ${esc.h}set() doesn't work in these demos
${esc.h}set( ${esc.d}base = ${esc.d}link.self.anchor('fullDemo') )
<a href="${esc.d}base.param('select','this')">this</a>
<a href="${esc.d}base.param('select','that')">that</a>##
#end##
</textarea>
  <br>
  <input type="submit" value="$demo.try">
  #if( $params.layout )
  <input type="hidden" name="layout" value="$params.layout">
  #end
</form>

#if( $params.fullDemo )
$demo.mainResultsIntro:
<pre>
  $render.eval($params.fullDemo)
</pre>
#end
</div>