(Opens New Window)
Mark as an Answer
how to define custom velocity variable in Journal template for custom class
May 18, 2012 9:27 AM
Rank: New Member
Join Date: March 25, 2012
Is there any way to use intialized object (using spring ) of a custom java class in journal velocity template. Scenario is such as;
There is a custom class "abc.java". It has one method "m1()" it returns an object. This Class object has been initialized by spring dependency.
There is one more class "xyz.java" this class set the object of "abc.java" in a variable "var1" like below.
abc obj1 = ((WebApplicationContext)WebUtil.getContext(request)).getBean(
Here, WebUtil and getBean are classes used to get context and bean respectively.
After doing above code i am getting null pointer exception on browser using localhost:8080.
After doing R&D i found that "vars.put("var1", obj1.m1());" returns null pointer exception.
Can any one please suggest that how will i fetch the object in "var1" so that i could use it in journal template.
Sign in to vote.
Please sign in to flag this as inappropriate.