You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Ed Yu <ek...@asgnet.psc.sc.edu> on 2002/07/21 04:51:22 UTC
RE: What am I doing wrong here ($link) (Mystery Solved - documentation error)
After looking into the source code, I've found out the problem. Here is
the documentation from
http://www.teamup.com/jakarta-velocity-tools/struts/docs/LinkTool.html
Method Overview
.
.
getQueryData() Returns this instance's query data.
getContextURI() Returns the URI that addresses this web application.
.
.
The method getContextURI() does not exists, the getContextURL() does.
The reason why $link render nothing because the way the LinkTool is
written, it only creates different instances when invoking its methods.
So I guess the documentation is what needs to be fixed.
Here is the code:
<html>
$errors<br>
$form<br>
$msg<br>
$link<br>
\$link - [$link]<br>
\$link.getContextURI() - [$link.getContextURI()]<br>
\$link.getContextURL() - [$link.getContextURL()]<br>
\$link.baseRef - [$link.baseRef]<br>
\$link.setURI("linktest.vm") - [$link.setURI("linktest.vm")]<br>
\$link.setURI("linktest.vm").getContextURI() -
[$link.setURI("linktest.vm").getContextURI()]<br>
\$link.setURI("linktest.vm").getContextURL() -
[$link.setURI("linktest.vm").getContextURL()]<br>
</html>
Here is the output:
org.apache.velocity.tools.struts.ErrorsTool@c623af
org.apache.velocity.tools.struts.FormTool@50ca0c
org.apache.velocity.tools.struts.MessageTool@e753
$link - []
\$link.getContextURI() - [$link.getContextURI()]
$link.getContextURL() - [http://localhost:8080/VelocityStrutsTest]
$link.baseRef - [http://localhost:8080/VelocityStrutsTest/linktest.vm]
$link.setURI("linktest.vm") - [linktest.vm]
\$link.setURI("linktest.vm").getContextURI() -
[$link.setURI("linktest.vm").getContextURI()]
$link.setURI("linktest.vm").getContextURL() -
[http://localhost:8080/VelocityStrutsTest]
> -----Original Message-----
> From: Geir Magnusson Jr. [SMTP:geirm@adeptra.com]
> Sent: Saturday, July 20, 2002 10:37 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: What am I doing wrong here ($link)
>
> On 7/20/02 10:22 PM, "Ed Yu" <ek...@asgnet.psc.sc.edu> wrote:
>
> > Yeah, strange isn't it, here is another test:
> >
> > <html>
> > $errors<br>
> > $form<br>
> > $msg<br>
> > $link<br>
> > \$link - [$link]<br>
> > \$link.getContextURI() - [$link.getContextURI()]<br>
> > \$link.baseRef - [$link.baseRef]<br>
> > \$link.setURI("linktest.vm") - [$link.setURI("linktest.vm")]<br>
> > </html>
> >
> > Here is the output:
> >
> > org.apache.velocity.tools.struts.ErrorsTool@b122a1
> > org.apache.velocity.tools.struts.FormTool@589e56
> > org.apache.velocity.tools.struts.MessageTool@33a6f
> >
> > $link - []
> > \$link.getContextURI() - [$link.getContextURI()]
> > $link.baseRef -
> [http://localhost:8080/VelocityStrutsTest/linktest.vm]
> > $link.setURI("linktest.vm") - [linktest.vm]
> >
>
> So it appears someone cleverly implemented toString() such that it
> outputs
> "".
>
> What I am trying to get as is if there is a public method
> getContextURI()...
>
> > Here is the log:
> >
> > 2002-07-20 22:33:21 - /VelocityStrutsTest: Velocity [info]
> > ResourceManager : found /linktest.vm with loader
> > org.apache.velocity.tools.view.servlet.WebappLoader
> > 2002-07-20 22:33:21 - /VelocityStrutsTest: Velocity [warn]
> > org.apache.velocity.runtime.exception.ReferenceException: reference
> :
> > template = /linktest.vm [line 7,column 27] : $link.getContextURI()
> is
> > not a valid reference.
> >
> >> -----Original Message-----
> >> From: Geir Magnusson Jr. [SMTP:geirm@adeptra.com]
> >> Sent: Saturday, July 20, 2002 7:17 PM
> >> To: velocity-user@jakarta.apache.org
> >> Subject: Re: What am I doing wrong here ($link)
> >>
> >> On 7/20/02 6:20 PM, "Ed Yu" <ek...@asgnet.psc.sc.edu> wrote:
> >>
> >>> Velocity-1.3-dev.jar and I've checked out the velocity-tools from
> >> the
> >>> CVS last nite. To answer your question, $link does not print out
> >>> anything but the $link.baseRef does output the current URL.
> >>>
> >>
> >> If you put
> >>
> >> $link
> >>
> >> In a template, you get no output?
> >>
> >> --
> >> Geir Magnusson Jr.
> >> Research & Development, Adeptra Inc.
> >> geirm@adeptra.com
> >> +1-203-247-1713
> >>
> >>
> >>
> >> --
> >> To unsubscribe, e-mail:
> >> <ma...@jakarta.apache.org>
> >> For additional commands, e-mail:
> >> <ma...@jakarta.apache.org>
> >>
> >
> > --
> > To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> > For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >
>
> --
> Geir Magnusson Jr.
> Research & Development, Adeptra Inc.
> geirm@adeptra.com
> +1-203-247-1713
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>
Re: What am I doing wrong here ($link) (Mystery Solved - documentation error)
Posted by Gabriel Sidler <si...@teamup.com>.
Thanks for finding this. I take care of it.
Ed Yu wrote:
[...]
> The reason why $link render nothing because the way the LinkTool is
> written, it only creates different instances when invoking its methods.
>
Yes, the idea is that you call methods of the link tool repeatedly to
build a URI, for example:
$link.setURI("login.do").addQueryData("key1", "val 1").addQueryData("key2", "val 2")
Each method call returns an updated instance of the link tool. Finally,
the toString() method which is called automatically by Velocity, returns a string
representation of the URI.
Gabe
> So I guess the documentation is what needs to be fixed.
>
> Here is the code:
> <html>
> $errors<br>
> $form<br>
> $msg<br>
> $link<br>
> \$link - [$link]<br>
> \$link.getContextURI() - [$link.getContextURI()]<br>
> \$link.getContextURL() - [$link.getContextURL()]<br>
> \$link.baseRef - [$link.baseRef]<br>
> \$link.setURI("linktest.vm") - [$link.setURI("linktest.vm")]<br>
> \$link.setURI("linktest.vm").getContextURI() -
> [$link.setURI("linktest.vm").getContextURI()]<br>
> \$link.setURI("linktest.vm").getContextURL() -
> [$link.setURI("linktest.vm").getContextURL()]<br>
> </html>
>
> Here is the output:
> org.apache.velocity.tools.struts.ErrorsTool@c623af
> org.apache.velocity.tools.struts.FormTool@50ca0c
> org.apache.velocity.tools.struts.MessageTool@e753
>
> $link - []
> \$link.getContextURI() - [$link.getContextURI()]
> $link.getContextURL() - [http://localhost:8080/VelocityStrutsTest]
> $link.baseRef - [http://localhost:8080/VelocityStrutsTest/linktest.vm]
> $link.setURI("linktest.vm") - [linktest.vm]
> \$link.setURI("linktest.vm").getContextURI() -
> [$link.setURI("linktest.vm").getContextURI()]
> $link.setURI("linktest.vm").getContextURL() -
> [http://localhost:8080/VelocityStrutsTest]
>
>
>>-----Original Message-----
>>From: Geir Magnusson Jr. [SMTP:geirm@adeptra.com]
>>Sent: Saturday, July 20, 2002 10:37 PM
>>To: velocity-user@jakarta.apache.org
>>Subject: Re: What am I doing wrong here ($link)
>>
>>On 7/20/02 10:22 PM, "Ed Yu" <ek...@asgnet.psc.sc.edu> wrote:
>>
>>
>>>Yeah, strange isn't it, here is another test:
>>>
>>><html>
>>>$errors<br>
>>>$form<br>
>>>$msg<br>
>>>$link<br>
>>>\$link - [$link]<br>
>>>\$link.getContextURI() - [$link.getContextURI()]<br>
>>>\$link.baseRef - [$link.baseRef]<br>
>>>\$link.setURI("linktest.vm") - [$link.setURI("linktest.vm")]<br>
>>></html>
>>>
>>>Here is the output:
>>>
>>>org.apache.velocity.tools.struts.ErrorsTool@b122a1
>>>org.apache.velocity.tools.struts.FormTool@589e56
>>>org.apache.velocity.tools.struts.MessageTool@33a6f
>>>
>>>$link - []
>>>\$link.getContextURI() - [$link.getContextURI()]
>>>$link.baseRef -
>>>
>>[http://localhost:8080/VelocityStrutsTest/linktest.vm]
>>
>>>$link.setURI("linktest.vm") - [linktest.vm]
>>>
>>>
>>So it appears someone cleverly implemented toString() such that it
>>outputs
>>"".
>>
>>What I am trying to get as is if there is a public method
>>getContextURI()...
>>
>>
>>>Here is the log:
>>>
>>>2002-07-20 22:33:21 - /VelocityStrutsTest: Velocity [info]
>>>ResourceManager : found /linktest.vm with loader
>>>org.apache.velocity.tools.view.servlet.WebappLoader
>>>2002-07-20 22:33:21 - /VelocityStrutsTest: Velocity [warn]
>>>org.apache.velocity.runtime.exception.ReferenceException: reference
>>>
>>:
>>
>>>template = /linktest.vm [line 7,column 27] : $link.getContextURI()
>>>
>>is
>>
>>>not a valid reference.
>>>
>>>
>>>>-----Original Message-----
>>>>From: Geir Magnusson Jr. [SMTP:geirm@adeptra.com]
>>>>Sent: Saturday, July 20, 2002 7:17 PM
>>>>To: velocity-user@jakarta.apache.org
>>>>Subject: Re: What am I doing wrong here ($link)
>>>>
>>>>On 7/20/02 6:20 PM, "Ed Yu" <ek...@asgnet.psc.sc.edu> wrote:
>>>>
>>>>
>>>>>Velocity-1.3-dev.jar and I've checked out the velocity-tools from
>>>>>
>>>>the
>>>>
>>>>>CVS last nite. To answer your question, $link does not print out
>>>>>anything but the $link.baseRef does output the current URL.
>>>>>
>>>>>
>>>>If you put
>>>>
>>>> $link
>>>>
>>>>In a template, you get no output?
>>>>
>>>>--
>>>>Geir Magnusson Jr.
>>>>Research & Development, Adeptra Inc.
>>>>geirm@adeptra.com
>>>>+1-203-247-1713
>>>>
>>>>
>>>>
>>>>--
>>>>To unsubscribe, e-mail:
>>>><ma...@jakarta.apache.org>
>>>>For additional commands, e-mail:
>>>><ma...@jakarta.apache.org>
>>>>
>>>--
>>>To unsubscribe, e-mail:
>>><ma...@jakarta.apache.org>
>>>For additional commands, e-mail:
>>><ma...@jakarta.apache.org>
>>>
>>--
>>Geir Magnusson Jr.
>>Research & Development, Adeptra Inc.
>>geirm@adeptra.com
>>+1-203-247-1713
>>
>>
>>
>>--
>>To unsubscribe, e-mail:
>><ma...@jakarta.apache.org>
>>For additional commands, e-mail:
>><ma...@jakarta.apache.org>
>>
>
> --
> To unsubscribe, e-mail: <ma...@jakarta.apache.org>
> For additional commands, e-mail: <ma...@jakarta.apache.org>
>
>
--
--
Gabriel Sidler
Software Engineer, Eivycom GmbH, Zurich, Switzerland
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>