Skip to content

TEDEFO-5220 Format the values displayed by expression blocks in EFX 2 templates - #182

Merged
rousso merged 3 commits into
developfrom
feature/TEDEFO-4794-output-formatting
Oct 4, 2026
Merged

rousso merged 3 commits into
developfrom
feature/TEDEFO-4794-output-formatting

Conversation

@rousso

@rousso rousso commented Oct 3, 2026 •

Copy link
Copy Markdown
Contributor

Formatted expression blocks in EFX 2 templates

TEDEFO-5220, TEDEFO-5241 and TEDEFO-5244

Based on #181. It needs OP-TED/eForms-SDK#1436 for the grammar (TEDEFO-5219) and OP-TED/eforms-core-java#71 for the data types (TEDEFO-5239). Until the SDK pull request is merged, the build on GitHub fails.

Formatting

Every value that an EFX 2 template displays is now formatted according to its type, and format options can follow a pipe inside the expression block, as in ${BT-00-Number|2}:

Value Without options Options
number, integer up to 9 decimals, with the configured separators a number of decimals, from 0 to 9
amount, measure, duration (field) its number, followed by the label of its unit a number of decimals; no-unit
calculated duration its number of months, or of days, followed by the label of that unit a number of decimals; no-unit
date, time short style short, medium, long
any other value as it is
  • no-formatting displays the value of a field as entered, and the value of any other expression as it is, without a unit.
  • $value is formatted like the field it refers to.
  • An absent value displays nothing. A list is formatted value by value, and a list of values with a unit needs no-unit.
  • The number is the quantity that selects the plural form of the label of the unit.

The label key of a unit comes from the metadata: for a field, the root code list of its attribute field, found with the new SymbolResolver.getAttributeOfField(); for a calculated duration, the list name of the type of the attribute of duration (timeperiod), through the new SymbolResolver.getDataType().

In the view templates of SDK 2, this formats 269 dates displayed with $value and 177 numbers. None displays an amount, a measure or a duration without a formatting function, so no unit appears twice.

Other changes

  • The implicit formatting of dates and times moves from the expression blocks to the formatted expression blocks, so the expression blocks inside labels are no longer formatted.
  • The value of an attribute field is composed in one method of EfxExpressionTranslatorV2, also used by the formatted expression blocks and by the label shorthand (#{BT-00-Code}, #value).
  • TEDEFO-5241, in a separate commit: errors take the parser context from the call stack (peekParserContext()), instead of receiving it from method to method. No translation and no error message changes.
  • TEDEFO-5244, in a separate commit: dependencies.json names the code lists of a rule codelists instead of codeLists, as "codelist" is one word across the SDK.
  • SymbolResolver has two new methods, getDataType() and getAttributeOfField(). Other implementations, such as the MDM's, must add them.

Validation

@rousso
rousso force-pushed the feature/TEDEFO-4794-output-formatting branch from a71ea95 to 1a0dd8d Compare October 4, 2026 00:24
Base automatically changed from feature/TEDEFO-4794-template-model to develop October 4, 2026 11:57
@rousso
rousso merged commit d29eb09 into develop Oct 4, 2026
2 of 4 checks passed
@rousso
rousso deleted the feature/TEDEFO-4794-output-formatting branch October 4, 2026 12:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant