Re: [htmltmpl-java] access to tmpl_var inside of tmpl_loop
Status: Beta
Brought to you by:
bluesmoon
From: Philip S T. <phi...@gm...> - 2002-09-04 09:52:43
|
On Wed, 4 Sep 2002, Thomas Wabner wrote: > // a normal template variable > template.setParam("sessionID",sessionID); > // a template loop > template.setParam("newsloop",Newsmanager.getNews()); > .... > > in html: > ..... > <tmpl_loop newsloop> > news: <tmpl_var news><br> > sessionID: <tmpl_var sessionID> > </tmpl_loop> > ..... > > the problem is, that the var "news" is correct set > inside the loop, but the outside of the loop declared > variable "sessionID" is not set. > > How can i access tmpl_vars inside the > loop, which are not declared in the loop-hashtable? This is basically what global_vars in the perl version of HTML::Template does. As of now, it's not possible in the java version, and my initial intent was not to support it, but it seems like there are people who would want it in, so the next version would most likely have global_vars support. For now, you'll have to use a workaround, and add sessionID to each of your loop elements. Something like this: Vector v = Newsmanager.getNews(); for(Enumeration e = v.elements(); e.hasMoreElements();) { Hashtable h = e.nextElement(); h.put("sessionID", sessionID); } I'll add support for it in the next version, and you're welcome to see if you can too. Philip -- We'll pivot at warp 2 and bring all tubes to bear, Mr. Sulu! |