Package com.avoka.tm.util
Class VelTemplate
- java.lang.Object
-
- com.avoka.tm.util.VelTemplate
-
public class VelTemplate extends Object
Provides a Apache Velocity templating class.
Examples
Email Template from Service Parameter
Provides an example creating an email body message using a Velocity template provided as a service parameter.
import com.avoka.tm.util.* String emailTemplate = svcDef.paramsMap["emailTemplate"] User user = ... String emailMessage = new VelTemplate() .setTemplate(emailTemplate) .addModelValue("user", user) .merge()
Email Template from Organization Property
Provides an example creating an email body message using a Velocity template provided from an Organization property.
import com.avoka.tm.query.* import com.avoka.tm.util.* String emailTemplate = new PropertyQuery() .setName("HTML Email Welcome") .setClientCode("maguire") .getValue() User user = ... String emailMessage = new VelTemplate() .setTemplate(emailTemplate) .addModelValue("user", user) .merge()
- Since:
- 5.0.0
- See Also:
PropertyQuery
-
-
Constructor Summary
Constructors Constructor Description VelTemplate()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description VelTemplate
addModelValue(String key, Object value)
Set the model key and value to merge with the template.String
merge()
Merge the velocity template with the model and return the evaluated text value.VelTemplate
setModel(Map<String,Object> model)
Set the model value to merge with the template.VelTemplate
setTemplate(String template)
Set the Velocity template value.
-
-
-
Method Detail
-
setTemplate
public VelTemplate setTemplate(String template)
Set the Velocity template value.- Parameters:
template
- the velocity template value- Returns:
- the vel template
-
setModel
public VelTemplate setModel(Map<String,Object> model)
Set the model value to merge with the template.- Parameters:
model
- the model value to merge with the template (required)- Returns:
- the vel template
-
addModelValue
public VelTemplate addModelValue(String key, Object value)
Set the model key and value to merge with the template.- Parameters:
key
- the model key to add (required)value
- the model value to add (required)- Returns:
- the vel template
-
merge
public String merge()
Merge the velocity template with the model and return the evaluated text value.- Returns:
- the evaluated text value from merging the Velocity template with the model
-
-