velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Denis <j...@respublica.fr>
Subject Re: Accessing objects from an ArrayList
Date Sat, 16 Nov 2002 12:17:43 GMT
Hi Rafael
samedi 16 novembre 2002, à 05:03  am, Rafael Steil a écrit :

>
> 	Hi, supose I have a class:
>
> class MyClass
> {
> 	private String name;
> 	
> 	public MyClass(String name)
> 	{
> 		this.name = name;
> 	}
>
> 	public String getName()
> 	{
> 		return name;
> 	}
> }
>
> Now I want to make 'n' MyClass objects availiable to velocity. Why 
> can't
> I do
>
> myArrayList.add(new MyClass("name 1"));
> myArrayList.add(new MyClass("name 2"));
> ...
> context.put("list", myArrayLIst);
>
> and then use
>
> #foreach ($item in list)
> 	$list.getName()
> #end

$item.getName()
Doesn't work?

-- Denis.

--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message