> Had a chance to try it out. The way Velocity accesses static methods > is described here: > > http://velocity.apache.org/engine/releases/velocity-1.6.2/developer-guide.html#supportforstaticclasses > > For Click you can do something like: > > public void onInit() { > addModel("velocity", Velocity.class); > } > > Then in your template you can access the resourceExists method as follows: > > #if ($velocity.resourceExists("/xyz.htm")) > #parse(...) > #end > > That said, the resourceExists method didn't work for me (not sure > why), so I ended up writing my own method: > > public class Util { > public static void resourceExists(String resourceName) { > try { > Context context = Context.getThreadLocalContext(); > > // First check on the servlet context path > boolean hasTemplate = > context.getServletContext().getResource(resourceName) != null; > if (!hasTemplate) { > > // Second check on the classpath > hasTemplate = ClickUtils.getResource(resourceName, > Util.class) != null; > } > > } catch (MalformedURLException e) { > throw new RuntimeException(e); > } > > return hasTemplate; > } > > You can use it as follows: > > public void onInit() { > addModel("util", Util.class); > } > > Hope this helps. >
Bob, thanks a lot! I haven't tried this out yet though. Regards, Prem
