Generation proces

Here the process generation schema used by RTFTemplate :

  • Step Parse RTF model source (1) consist to load RTF model source into RTFDocument structure . RTFDocument contains the whole RTF model, which split RTF elements interpretated by RTFTemplate as fields (RTFField), bookmarks (RTFBookmark)...
  • Step Transform RTF Document (2) consist to transform the RTFDocument structure, in other words :
    • replace RTF code with specific macro swith template engine selected (ex : replace bookmark with #foreach macro when RTFTemplate is used with Velocity).
    • remove some RTF code. For merge fields (MERGEFIELD), RTFTemplate remove the character " which include merge fields.

    This step requires the JAVA context OR the XML file which contains fields avalaible (*.fields.xml) of the RTF model. Indead transformation step is able to generate loop macro (#foreach, #list,...) swith selected template engine (Velocity, Freemarker,...).

    When RTFTemplate will be integrated in your application, some list of your context could be empty. Loop generation is done with introspection of JAVA objects. If your list is empty, RTFTemplate will not able to to generate fields which are included into a loop.

    To resolve this problem, XML file of fields available is required when you want integrate RTFTemplate in your application. This file can be generate with the class AbstractRTFUseCase. (before integrate RTFTemplate). This file contains fields information to know if the field is a list or not.

    That's why, it's very important to put the context with all data, when class AbstractRTFUseCase is implemented.

    Result of this step give new RTFDocument which contains macro swith selected template engine.

  • Etape Merge with template engine (3) consist to merge transformed RTFDocument with JAVA context. This step use selected template engine to merge transformed RTFDocument with context to give RTF target.

Each steps of the process can be selected among default implementation of RTFTemplate ((Velocity and Freemarker template engine) or redefined. This configuration can be done with JAVA code or with XML file Spring configuration. For more information, click Pour plus d'informations, cliquez here