On Wed, 2 Mar 2005 22:33:47 -0800, Shinobu Kawai <[EMAIL PROTECTED]> wrote: > Hi Ravikanth, > > > I would like to create a object reference in template using "new" > > keyword like what we do in java > > > > String obj = new String()
<cringe>not a best practice!</cringe> :) > > I need to put RenderTool instance in context and use it to fix some > > problem. I know that i can put it to context from the java code where > > the template is being called or using toolbox.xml But as my > > application is standalone and in production and i don't want to change > > the java code to fix the issue, i want to handle it in template. > > If you really, really, really want to do it, check out the deprecated > ToolLoader. > > http://jakarta.apache.org/velocity/tools/javadoc/org/apache/velocity/tools/generic/ToolLoader.html but this is gone in VelocityTools 1.2 > Or, you can call Class#newInstance from anywhere. > See Will's HackingVelocity power point about how to do this. > http://wiki.apache.org/jakarta-velocity/HackingVelocity > ## Under "An Evil Velocity Template" if you have to do this, i recommend this way. just to make sure it's clear that it's not a good thing to be doing. ;-) > > And also is there any way to get the reference to the context in > > templates when Velocity.mergeTemplate() is being used, though the > > context reference is not kept in context. > > None that I know of. > > > Is it possible to achieve this ? Any suggestions are most welcome. > > What would be the risks of adding the two lines to your java code? If > none of the templates already use the references "$render" or "$ctx", > then I think you can update it without much worry. > > I also think there was a post in bugzilla some while ago about a > toolbox for standalone apps. > > Best regards, > -- Shinobu > > -- > Shinobu Kawai <[EMAIL PROTECTED]> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: [EMAIL PROTECTED] > For additional commands, e-mail: [EMAIL PROTECTED] > > --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]