"Henning P. Schmiedehausen" <[EMAIL PROTECTED]> writes:

>#set ($_action = $link.setAction("Topic"))
>#set ($_uri = $link.addPathInfo("catid", $catid).setPage("forum,TopicList.vm"))

Hm,

well, one thing that I should point out is the fact, that there _is_ some 
magic behind the scenes regarding the $link tool.

Normally, the $link tool is a TemplateLink object. Everytime you write
something like 

#set($foo = $link.addPathInfo("this", "that").setPage("somewhere"))

then $foo simply points to $link (You can check it: $foo is the same
TemplateLink object as the one that $link references) and the internal
state of $link is changed.

To get the string value of your link you must call toString() 
on this object. It then returns the
"http:/xxx/xxx/xxx/this/that/template/somewhere" string _AND RESETS
THE INTERNAL LIST OF PATHINFO AND QUERYDATA PARAMETERS_.

Otherwise, all the $link calls in a page would get more and more
parameters added to its output.

Unfortunately, this means that

#set ($foo = $link.addPathInfo("foo", "bar"))
#set ($foo = $link.addPathInfo("one", "two"))
<pre>$foo</pre>

returns 

http://xxx/yyy/zzz/foo/bar/one/two

and

#set ($foo = $link.addPathInfo("foo", "bar"))
<pre>$foo</pre>
#set ($foo = $link.addPathInfo("one", "two"))
<pre>$foo</pre>

returns

http://xxx/yyy/zzz/foo/bar
http://xxx/yyy/zzz/one/two

Only the $foo output which calls toString() on $foo actually resets
the Query/Pathinfo parameters.

You can work around this by explicitly fetching the link from the
Template Link object:

#set ($foo = $link.addPathInfo("foo", "bar").toString())
#set ($foo = $link.addPathInfo("one", "two").toString())
<pre>$foo</pre>

returns http://xxx/yyy/zzz/one/two

and $foo is now a java.lang.String, not an
org.apache.turbine.services.pull.tools.TemplateLink object.

While I'd still advise against the usage of direct method calls in
macro parameters, I was actually wrong with the cause of your
problems. The main problem is, that $_action and $_uri still point to
the same object as the $link tool because you haven't called any of
the following methods:

getAbsoluteURI/getRelativeURI/getURI/getAbsoluteLink/getRelativeLink/toString

on the tool which return the current URI as a String object
instance. As long as you don't do this, the URI is stored in the
single instance of the tool in your context.  Which can only store one
URI.

Please try:

#set ($_action = $link.setAction("Topic").toString())
#set ($_uri = $link.addPathInfo("catid", 
$catid).setPage("forum,TopicList.vm").toString())
#createForm ("forumTopic" "post" $_action $_uri)

I just checked some clarifications into the HEAD of the 2.3 tree for
the TemplateLink tool. If you consider the toString() sucky, you can
write this with the very latest HEAD of 2.3:  ;-)

#set ($_action = $link.setAction("Topic").Link)
#set ($_uri = $link.addPathInfo("catid", $catid).setPage("forum,TopicList.vm").Link)
#createForm ("forumTopic" "post" $_action $_uri)

        Regards
                Henning


-- 
Dipl.-Inf. (Univ.) Henning P. Schmiedehausen          INTERMETA GmbH
[EMAIL PROTECTED]        +49 9131 50 654 0   http://www.intermeta.de/

Java, perl, Solaris, Linux, xSP Consulting, Web Services 
freelance consultant -- Jakarta Turbine Development  -- hero for hire

"You are being far too rational for this discussion."  
       --- Scott Robert Ladd in <[EMAIL PROTECTED]>

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to