velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Kalyani Kale" <>
Subject RE: Can't access public fields
Date Fri, 15 Oct 2004 09:25:21 GMT
Does your Restaurant class contain getAddress method? Since address is a
public field, u must not have written a getter method for it.

When u say, $r.address, velocity will try to call getAddress method on
object r (provided r is not a hashtable).

In case of hashtable, u can directly use key names to get the value.


-----Original Message-----
From: Rocchi Cesare [] 
Sent: Friday, October 15, 2004 2:35 PM
To: Velocity Users List
Subject: Can't access public fields


I have defined a Restaurant class like this:

public class Restaurant {
	public String name = "";
	public String address = "";

As you can see fields are public, but as far as I tried I can't access 
those fields from a velocity context. If I put the rest in a context like:

Restaurant r = new Restaurant(); = "test";
r.address = "bla bla ";
context.put("rest", r);

there is no way to get the value of address by means of


I thought it was possible. Is it? Otherwise I should convert my class 
into an hashtable. That works, already tried.



              Cesare Rocchi

To unsubscribe, e-mail:
For additional commands, e-mail:

To unsubscribe, e-mail:
For additional commands, e-mail:

View raw message