XML Template - Advanced case

The main approach based on elements with "cj:" namespace covers 99% of all actual cases. If you have a case that belongs to the remaining 1% and need extra functionality then consider using Thymeleaf template engine. It is a part of the platform that Codejig system is running on. So it is enabled right away and does need any additional configuration. 


Here are two examples, just to show a difference.


Example 1

Codejig style implementation:

<a cj:if="object.f47.f77">
  The parent tag will be added to the result only if object.f47.f77 is not null.
</a>

Thymeleaf implementation:


<a
th:if="${object.getField47().getField77()}">
  The parent tag will be added to the result only if object.f47.f77 is not null.
</a>

Example 2

Codejig style implementation:

<a cj:with="my_var = object.f47.f77">
  <b>The value is {my_var.f477}</b>
  <b>The value is {my_var.f4478:V1234}</b>
</a>

Thymeleaf implementation:

<a th:with="my_var = ${object.getField47().getField77()}">
  <b th:text="'The value is' + ${{my_var.getField4477()}}"/>
  <b th:text="'The value is' + ${valueFormatter.format(my_var.getField4478(), 1234L)}"/>
</a>

As you may see we use namespace "th:" for Thymeleaf implementation. Also data fields are referred a bit differently. And finally, to format data you may need an additional service object - valueFormatter.


The valueFormatter object provides a number of methods:


Method signatureDescription
format(AbstractMetaEntity sourceItem, Long viewId)
Use for applying concrete string view
formatField(AbstractMetaEntity sourceItem, Long fieldId)
Use for applying a default string view for the field
formatFloat(AbstractMetaEntity sourceItem, Long fieldId, Integer scale)
Use for applying float number format together with "Decimal" primitive types
formatFloat(Object value, Integer scale)
Use for applying float number format together with "Double" primitive types
formatDecimal(Object value, Integer length, Boolean leadingZeros)
Use for applying integer number format
formatBoolean(Object value, Boolean uppercase)
Use for applying boolean value format