Velocity documentation tells that to resolve a variablev a
#set derective or POJO with corresponding property should be used. Is there a way to provide a custome resolver? E.g. when
$client appears in template, resolver
go to database, retrieve
Client entity, get
name field and fill
$client place holder. Does velocity template engine support such extensions?
You may try with the ReferenceInsertionHandler, but its purpose is rather to filter (aka modify, alter in some way) displayed values than to fetch values from Velocity references.
Such a task would typically be done by the context objects themselves. That is,
$client can contain an object which knows how to fetch and return the client's name on its
You can also use objects with getters and setters, so that you can write
$client.name as long as
$client.address. You'll get yourself doing some kind of ORM. As a side note, there are existing libraries easing this task for Velocity.