Hello All,

Thanks to Henning, that was the solution:
#createForm ("forumnotes" "post" $link.setAction("Notes").toString()      
$link.setPage("forum,NotesList.vm").addPathInfo("topicid", 
$topic.FtId).toString()) 

the result is:
<form name="forumnotes" method="post" Accept-Charset="ISO-8859-2"   
action="http://localhost:8080/portal/servlet/portal/action/Notes"; >
      <input type="hidden" name="nextScreen" 
value="http://localhost:8080/portal/servlet/portal/template/forum%2CNotesList.vm/topicid/4";>

with toString() it doesn't duplicates, and can be direct parameter!

Henning P. Schmiedehausen writes:
> "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/toStri
>ng
>
> 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

-- 
thx,
----------------------------------------------------
Zoltan Zidarics programmer
PTE University Pecs, Hungary
icq: 43288694


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

Reply via email to