velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jakub Bogusławski" <j.boguslaw...@post.pl>
Subject Problem with passing object array into Velocity context
Date Thu, 07 Nov 2002 13:19:53 GMT
Hello

I have problem with passing array of objects into Velocity context, or
rather with accessing fields of these objects. Here is some of my
code:

Java Servlet

class Category {
 String parent="", name="";
 int id=0;
			
 public Category(int idp, String parentp, String namep) {
  id=idp;
  name=namep;
  parent=parentp;
 }

}

Category[] categories = new Category[4];
categories[0]=new Category(10001,"Top","Ankieta");
categories[1]=new Category(10002,"Top","Badania");
categories[2]=new Category(10003,"Top","Rezultaty");
categories[3]=new Category(10004,"Top","Wydruki");
			
ctx.put("categoriesList",categories);

and Velocity template

<select name="tCategory">
#foreach( $category in $categoriesList )
	 <option VALUE="$category.id"> $category.parent >> $category.name
</OPTION>
#end
</select>

And now html output!!!

<select name="tCategory">
	 <option VALUE="$category.id"> $category.parent >> $category.name
</OPTION>
	 <option VALUE="$category.id"> $category.parent >> $category.name
</OPTION>
	 <option VALUE="$category.id"> $category.parent >> $category.name
</OPTION>
	 <option VALUE="$category.id"> $category.parent >> $category.name
</OPTION>
</SELECT>

Please help!! What am I doing wrong??

Kuba

--
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