You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Jürgen Hoffmann <jh...@byteaction.de> on 2003/02/14 17:43:47 UTC
$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: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
AW: $link mystery
Posted by Jürgen Hoffmann <jh...@byteaction.de>.
Hi,
I have written a little paging macro which prints the links to the
direct pages. And I have to add information to the link... To add the
page this link belongs to...
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
-----Ursprüngliche Nachricht-----
Von: Bill [mailto:bhalpin@collaborativefusion.com]
Gesendet: Freitag, 14. Februar 2003 17:55
An: Turbine Users List
Betreff: Re: $link mystery
On Fri, 2003-02-14 at 11:43, Jürgen Hoffmann wrote:
> 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%2Cdo
> e.
> vm/action/john%2Cdoe.vm
> Testlink2: http://localhost:8080/accounting/servlet/accounting
>
The links are correct. setAction is supposed to point to an action
class, not a template. Thats why the link looks different.
> 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?
Any reason why you have to use a macro? Why not do the manipulation in
an action or screen class? And why would you add extra information to
the link? Maybe you could give me clearer idea of the purpose?
Maybe I'm just looking at this in the wrong light...
-b
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
Re: $link mystery
Posted by Bill <bh...@collaborativefusion.com>.
On Fri, 2003-02-14 at 11:43, Jürgen Hoffmann wrote:
> 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
>
The links are correct. setAction is supposed to point to an action
class, not a template. Thats why the link looks different.
> 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?
Any reason why you have to use a macro? Why not do the manipulation in
an action or screen class? And why would you add extra information to
the link? Maybe you could give me clearer idea of the purpose?
Maybe I'm just looking at this in the wrong light...
-b
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
AW: $link mystery
Posted by Jürgen Hoffmann <jh...@byteaction.de>.
To clear this one out...
The first time i am trying to put the $link + page into $testlink. The
second Time I am trying to assign $testlink + Action to $testlink2
But $testlink2 is empty, and $testlink has the information. That is the
Problem.
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
-----Ursprüngliche Nachricht-----
Von: Marc Lustig [mailto:mail@marclustig.com]
Gesendet: Freitag, 14. Februar 2003 17:58
An: Turbine Users List
Betreff: AW: $link mystery
If I understand you correct you wonder why nothing is added to your path
when you use setAction()
My solution is to extend TemplateLink and add a method like this:
public DynamicURI addActionInfo(String actionMethodName) {
return addPathInfo("eventSubmit_do"+actionMethodName,"foo");
}
Now I create the action-info for the link like this:
<a href="$link.setAction("ActionsClass").addActionInfo("Actionmethod")">
MArc
> -----Ursprüngliche Nachricht-----
> Von: Jürgen Hoffmann [mailto:jh@byteaction.de]
> Gesendet: Freitag, 14. Februar 2003 17:44
> An: turbine-user@jakarta.apache.org
> Betreff: $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%2Cdo
> e.
> 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: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
AW: $link mystery
Posted by Marc Lustig <ma...@marclustig.com>.
If I understand you correct you wonder why nothing is added to your path
when you use setAction()
My solution is to extend TemplateLink and add a method like this:
public DynamicURI addActionInfo(String actionMethodName) {
return addPathInfo("eventSubmit_do"+actionMethodName,"foo");
}
Now I create the action-info for the link like this:
<a href="$link.setAction("ActionsClass").addActionInfo("Actionmethod")">
MArc
> -----Ursprüngliche Nachricht-----
> Von: Jürgen Hoffmann [mailto:jh@byteaction.de]
> Gesendet: Freitag, 14. Februar 2003 17:44
> An: turbine-user@jakarta.apache.org
> Betreff: $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: turbine-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: turbine-user-help@jakarta.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
RE: $link mystery
Posted by Chris K Chew <ch...@fenetics.com>.
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:jh@byteaction.de]
Sent: Friday, February 14, 2003 9:44 AM
To: turbine-user@jakarta.apache.org
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: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-user-help@jakarta.apache.org