Creating a FreeMarker transform

If none of the existing FreeMarker transforms meet your requirements, you may always create your own. FreeMarker transforms are Java classes configured to perform an inline conversion when used within a FreeMarker template.

How to do it...

To create your own FreeMarker transform, follow these steps:

  1. Create the Java class that implements the TemplateTransformModel Java class.
  2. Rebuild the Component containing the transform.
  3. Add the transform's Java class package name to the following Java property file so that it will be loaded on the CLASSPATH and available for use:

    ~framework/webapp/config/freemarkerTransforms.properties

  4. Restart OFBiz.
  5. Use the transform in a FreeMarker template by wrapping content in the transform tags.

How it works...

Writing a Java FreeMarker transformation is a simple way of extending FreeMarker data formatting capabilities for use across the entire OFBiz instance.

There's more...

There are many examples of custom FreeMarker transformations within the OFBiz distribution. For example, the content Component has implemented a number of these to assist in the sometimes tricky transformation of raw data into human readable formats:

~content/src/org/ofbiz/content/webapp/ftl

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.135.204.0