public class FreeMarkerContentHandlerFactory extends Object implements org.smooks.api.delivery.ContentHandlerFactory
Visitor
Creator class.
This templating solution relies on the Smooks JavaBean Cartridge
to perform the JavaBean population that's required by FreeMarker (for the data model).
<resource-config selector="target-element"> <resource>FreeMarker Resource - Inline orExample - URI based FreeMarker spec:URI
</resource> <!-- (Optional) The action to be applied on the template content. Should the content generated by the template: 1. replace ("REPLACE") the target element, or 2. be added to ("ADD_TO") the target element, or 3. be inserted before ("INSERT_BEFORE") the target element, or 4. be inserted after ("INSERT_AFTER") the target element. 5. be bound to ("BIND_TO") aBeanContext
variable named by the "bindId" param. Default "replace".--> <param name="action">REPLACE/ADD_TO/INSERT_BEFORE/INSERT_AFTER</param> <!-- (Optional) Should the template be applied before (true) or after (false) Smooks visits the child elements of the target element. Default "false".--> <param name="applyTemplateBefore">true/false</param> <!-- (Optional) The name of theOutputStreamResource
to which the result should be written. If set, the "action" param is ignored. --> <param name="outputStreamResource">xyzResource</param> <!-- (Optional) Template encoding. Default "UTF-8".--> <param name="encoding">encoding</param> <!-- (Optional) bindId when "action" is "BIND_TO". <param name="bindId">xxxx</param> </resource-config>
<resource-config selector="target-element">
<!-- 1. See URIResourceLocator
-->
<resource>/com/acme/order-transform.ftl</resource>
</resource-config>
Example - Inlined FreeMarker spec:
<resource-config selector="target-element"> <!-- 1. Note how we have to specify the resource type when it's inlined. --> <!-- 2. Note how the inlined FreeMarker template is wrapped as an XML Comment. CDATA Section wrapping also works. --> <resource type="ftl"> <!-- Inline FreeMarker Template.... --> </resource> </resource-config>
Constructor and Description |
---|
FreeMarkerContentHandlerFactory() |
Modifier and Type | Method and Description |
---|---|
org.smooks.api.delivery.ContentHandler |
create(org.smooks.api.resource.config.ResourceConfig resourceConfig)
Create a FreeMarker based ContentHandler.
|
String |
getType() |
public org.smooks.api.delivery.ContentHandler create(org.smooks.api.resource.config.ResourceConfig resourceConfig) throws org.smooks.api.SmooksConfigException
create
in interface org.smooks.api.delivery.ContentHandlerFactory
resourceConfig
- The SmooksResourceConfiguration for the FreeMarker.ContentHandler
instance.org.smooks.api.SmooksConfigException
public String getType()
getType
in interface org.smooks.api.delivery.ContentHandlerFactory
Copyright © 2024. All rights reserved.