Re: [htmltmpl-java] Help!
Status: Beta
Brought to you by:
bluesmoon
From: Philip S T. <phi...@gm...> - 2002-07-01 04:35:55
|
On Sun, 30 Jun 2002, James Wu wrote: > Can I embed one loop into another? and how to do it in java side? Were you the one who asked this question on the users forum? Anyway, I'll answer it here too. Yes, you can. > <tmpl_loop loop1> > .... > <tmpl_loop loop2> > ... > </tmpl_loop> > </tmpl_loop> You'd have to have something like this: Hashtable( loop1 => Vector1 ( Hash1(loop2 => Vector2) Hash2(loop2 => Vector3) Hash3(loop2 => Vector4) ) ) Of course, Hashtable, Hash[1-3] would also have other elements. The first hashtable is optional, since it is created inside the template anyway. So, java would be like this: Template t = new Template(...); Vector v = new Vector(); for(outer_loop) { Hashtable h = new Hashtable(); h.put("field1", value1); ... Vector v2 = new Vector(); for(inner_loop) { Hashtable h2 = new Hashtable(); //populate h2 v2.addElement(h2); } h.put("loop2", v2); } t.setParam("loop1", v); And set any other params as you want them. Philip |