RE: [htmltmpl-java] testing for parameter existence
Status: Beta
Brought to you by:
bluesmoon
From: Costantino, D. <Dan...@gs...> - 2002-12-11 18:50:02
|
Philip, I downloaded and tested the new Template.java and tested the containsKey() method. Unfortunately, this method only works after a call to setParam(). For example, suppose I have the following in my template file: <tmpl_var name = foo> if (t.containsKey("foo")) { // succeed } else { // fail } that will always fail unless I do the following: t.setParam ("foo", "bar"); if (t.containsKey("foo")) { // succeed } else { // fail } Then it will succeed. For my purposes, I need to know if a parameter exists before I set its value. Is this a piece of functionality which could be added? Please let me know. Thanks -Dan -----Original Message----- From: Philip S Tellis [mailto:phi...@gm...] Sent: Tuesday, December 10, 2002 11:51 PM To: htm...@li... Subject: Re: [htmltmpl-java] testing for parameter existence On Tue, 10 Dec 2002, Costantino, Dan wrote: > I want to test for the existence of a parameter in a template. How > can I do this without generating a java.util.NoSuchElementException? > > At present, I simply wrap each getParam(<test_name>) call around a try ... Currently this seems to be the only way, but I think it is reasonable enough to add another method that will do what you want. Expect it in the next version, or get CVS in a few hours. Philip -- "If people could put rainbows in zoos, they'd do it." -- Hobbes ------------------------------------------------------- This sf.net email is sponsored by: With Great Power, Comes Great Responsibility Learn to use your power at OSDN's High Performance Computing Channel http://hpc.devchannel.org/ _______________________________________________ Html-tmpl-java-users mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/html-tmpl-java-users URL: http://html-tmpl-java.sourceforge.net/ |