You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Li Xiaoli-a17351 <a1...@motorola.com> on 2001/05/31 05:03:01 UTC
How to output VTL Properties?
Hello
I have a question about the output of VTL properties. I just try
#set($customer.address = "Address")
$customer.address
the output result is "$customer. address" instead of "Address".
So how can I output VTL properties?
Thanks
Charley
Re: How to output VTL Properties?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Li Xiaoli-a17351 wrote:
>
> Hello
>
> I have a question about the output of VTL properties. I just try
>
> #set($customer.address = "Address")
> $customer.address
>
> the output result is "$customer. address" instead of "Address".
> So how can I output VTL properties?
That is legitimate if the class customer is an instance of is public,
has a method setAddress( String ) that is public, and a method String
getAddress() that is public.
Let us know...
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."
Re: How to output VTL Properties?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Jon Stevens wrote:
>
> on 5/30/01 8:03 PM, "Li Xiaoli-a17351" <a1...@motorola.com> wrote:
>
> > Hello
> >
> > I have a question about the output of VTL properties. I just try
> >
> > #set($customer.address = "Address")
> > $customer.address
> >
> > the output result is "$customer. address" instead of "Address".
> > So how can I output VTL properties?
> >
> > Thanks
> > Charley
>
> That won't work. It isn't Java Bean friendly.
>
> Assuming:
>
> public class Customer
> {
> setAddress(String address)
> String getAddress()
> }
>
> Then:
>
> $customer.setAddress("Address")
>
> You can refer to it like this:
>
> $customer.Address
>
Actually, that *is* bean friendly. Given the Customer class is public
and the methods set/get are public, then Velocity should be perfectly
happy to do
#set($customer.address = "296 Cannon Rd.")
$customer.address
(I'll go back and respond to the original...)
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
"still climbing up to the shoulders..."
Re: How to output VTL Properties?
Posted by Jon Stevens <jo...@latchkey.com>.
on 5/30/01 8:03 PM, "Li Xiaoli-a17351" <a1...@motorola.com> wrote:
> Hello
>
> I have a question about the output of VTL properties. I just try
>
> #set($customer.address = "Address")
> $customer.address
>
> the output result is "$customer. address" instead of "Address".
> So how can I output VTL properties?
>
> Thanks
> Charley
That won't work. It isn't Java Bean friendly.
Assuming:
public class Customer
{
setAddress(String address)
String getAddress()
}
Then:
$customer.setAddress("Address")
You can refer to it like this:
$customer.Address
-jon
--
If you come from a Perl or PHP background, JSP is a way to take
your pain to new levels. --Anonymous
<http://jakarta.apache.org/velocity/ymtd/ymtd.html>