Details
-
Bug
-
Status: Closed
-
Major
-
Resolution: Incomplete
-
1.1-rc2
-
None
-
None
-
Operating System: All
Platform: All
-
5321
Description
I think that there should be an interface with a method of something like
Object
getVelocityProperty(String key);
that will provide for a way to manually determine what
object to retrieve with a given property name. Currently, there is no good way to access hashtable-
like structures without resorting to what essentially amounts to putting java code into the
template. (i.e. "$hash.get($key)")...
Velocity should allow developers to implement an
interface to get more control of velocity engine rendering, so that when the template calls for
$obj.property, a check is made to see if an object is an instance of that interface. If not, the
standard algorithm should be used to determine if this object has a getProperty() method. But if
the object does implement the interface, Velocity would call
getVelocityProperty("property") on it, and it would be up to the programmer to provide proper
logic to return the property. (in a Hashtable wrapper, the method would contain one line:
return hash.get(key);
This will not only give the programmer more control and force
them to pur less Java code into the template, but would also enable the developer to optimize the
most frequently accessed types of objects for performance as it will reduce the need to perform
reflection lookups.