Package com.avoka.tm.util
Class VelTemplate
- java.lang.Object
-
- com.avoka.tm.util.VelTemplate
-
public class VelTemplate extends java.lang.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(java.lang.String key, java.lang.Object value)
Set the model key and value to merge with the template.java.lang.String
merge()
Merge the velocity template with the model and return the evaluated text value.VelTemplate
setModel(java.util.Map<java.lang.String,java.lang.Object> model)
Set the model value to merge with the template.VelTemplate
setTemplate(java.lang.String template)
Set the Velocity template value.
-
-
-
Method Detail
-
setTemplate
public VelTemplate setTemplate(java.lang.String template)
Set the Velocity template value.- Parameters:
template
- the velocity template value- Returns:
- the vel template
-
setModel
public VelTemplate setModel(java.util.Map<java.lang.String,java.lang.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(java.lang.String key, java.lang.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 java.lang.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
-
-