This is a quirk with the TemplateLink tool. Take a look at the source code
for org.apache.turbine.util.template.TemplateLink
(http://jakarta.apache.org/turbine/turbine-2.2.0/xref/org/apache/turbine/uti
l/template/TemplateLink.html) -- this is the class that gets loaded as
$link.
1. You will notice that all of the methods "return this;". I guess this is
so that you can chain methods:
$link.setPage("").addPathInfo("","").addPathInfo("",""). The repercussion
is that you have to be careful not to set a $variable=$link and then call
another method on $link before calling $variable, or else your will have
unexpected output from $variable.toString().
2. You will further notice that the $link.toString() method calls
removePathInfo() and removeQueryData(), which is why your second link has
none of the info you previously set.
There are two things you do to get around this. First, never set a variable
in Velocity that equals the $link object directly. Instead, set variables
to equal $link.toString(). Second, extend template link to add convenience
methods to keep from repeating the same
$link.addPathInfo("x","2).addPathInfo("y","0"). The extension seems to work
better in my experience than using Macros. Search the turbine-user list for
the thread "URL Construction" which talks a little about extending
TemplateLink.
Good luck,
Chris
-----Original Message-----
From: J�rgen Hoffmann [mailto:[EMAIL PROTECTED]]
Sent: Friday, February 14, 2003 9:44 AM
To: [EMAIL PROTECTED]
Subject: $link mystery
Hi,
Can one explain me this? In my Template i have the following statements:
#set ( $testlink = $link.setPage("john,doe.vm") )
#set ( $testlink2 = $testlink.setAction("john,doe.vm") )
Testlink: $testlink<br/>
Testlink2: $testlink2
This becomes:
Testlink:
http://localhost:8080/accounting/servlet/accounting/template/john%2Cdoe.
vm/action/john%2Cdoe.vm
Testlink2: http://localhost:8080/accounting/servlet/accounting
What I am trying to do is Hand a Link over to a macro where I want to
add additional Information to the link. Is this an expected Behaviour?
Has someone done successfully what I am trying to do and can help me?
Kind regards
J�rgen Hoffmann
ByteACTION GmbH
cert. Perl Programmer
cert. Linux System Administrator
cert. Java Programmer
Besuchen Sie uns doch auf der CeBIT 2003
in Halle 4/Stand 70
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]