velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Patrick E. Whitesell" <pwhites...@clickability.com>
Subject Re: ReferenceException
Date Mon, 02 Jul 2001 22:46:08 GMT
piero de salvia wrote:

>Hi guys,
>
>It's one of those days when nothing works...
>
>I have:
>
>public class Hyperlink {
>
>	public String	Location;
>	public String	Label;
>}
>
>and in my servlet I do:
>
>Hyperlink hl = new Hyperlink();
>hl.Label = "/site/section"; 
>hl.Location = "Section";
>ctx.put("hl", hl);
>
>and in my template I do:
>
><a href="$hl.Location">$hl.Label</a>
>
>and my result is:
>
><a href="$hl.Location">$hl.Label</a>
>
>
>plus 2 ReferenceExceptions:
>
>Tue Jul 03 00:29:21 GMT+02:00 2001   [warn]
>org.apache.velocity.runtime.exception.ReferenceException:
>reference : template = /piergi/layout/navbar.vm [line
>6,column 42] : $hl.Location is not a valid reference.
>Tue Jul 03 00:29:21 GMT+02:00 2001   [warn]
>org.apache.velocity.runtime.exception.ReferenceException:
>reference : template = /piergi/layout/navbar.vm [line
>6,column 56] : $hl.Label is not a valid reference.
>
>
>Should I give up programming?
>
>piero de salvia
>
>__________________________________________________
>Do You Yahoo!?
>Get personalized email addresses from Yahoo! Mail
>http://personal.mail.yahoo.com/
>
You need getLocation() and getLabel() methods in your Hyperlink class. 
 The Velocity engine doesn't access the properties of Objects, it uses 
get/set methods to access them (as per the Beans spec).

So

$h1.Location

is interpreted as

h1.getLocation()



#set($h1.Location = "here")

would be interpreted as

h1.setLocation("here")

-- 
Patrick E. Whitesell
pwhitesell@clickability.com

***************************************
This e-mail message may contain confidential and/or legally privileged information. If you
are not the intended recipient(s), or the employee or agent responsible for delivery of this
message to the intended recipient(s), you are hereby notified that any dissemination, distribution
or copying of this e-mail message is strictly prohibited.If you have received this message
in error, please immediately notify the sender and delete this e-mail message from your computer.
DO NOT FORWARD THIS E-MAIL MESSAGE WITHOUT THE PERMISSION OF THE SENDER.




Mime
View raw message