JDynamiTe 2.0

Presentation

JDynamiTe is a simple yet powerful tool used to dynamically create documents in any format from "template" documents.

After some years of usage, hundreds of downloads and many useful feedbacks, JDynamiTe is back with a new release 2.0 (compatible with version 1.2) providing very interesting additional features.

Typical usage domains of JDynamiTe are:

  • dynamic Web pages creation,
  • text document generation,
  • source code generation...
  • in fact, any case where pre-defined documents (templates) have to be dynamically populated with data.

The main benefit of JDynamiTe is to allow a true separation between data (content), presentation (container) and content generation code (written in Java).

JDynamiTe does not include a specific template language, and it is not a complete framework. It is a simple "brick" in your software architecture, "glue" between your data model and your presentation model.

JDynamiTe is "only" a Java package, which is designed to be flexible and open.
JDynamiTe is free, under the GNU Library General Public License, version 3.
This project is hosted in SourceForge domain.

Examples - Getting started

Examples are better than long explanations!
The best way to start is probably to discover the various examples, from very simple case to more complex, in the new dedicated JDynamiTe examples pages here.
Each example is commented, and links to implemented feature documentation are provided.

Features/Concepts

  • JDynamiTe is a Java package which is very simple to use: you only need one class and few methods to parse and develop dynamic documents from templates (see examples).
  • These template documents can be in any text format.
  • There is no "template language", no control structure (such as "for", "while" ...) to add in templates.
  • JDynamiTe only needs to recognize three kinds of tag in the template document ("Variable", "Begin Dynamic Element", and "End Dynamic Element"). A "Dynamic Element" is a "block" which can be dynamically developed. Examples of use: list, table, enumeration, etc.
    See documentation JDynamiTe API documentation for more details.
  • Since JDynamiTe 2.0, there is a new kind of Dynamic Element: "XML Dynamic Elements" allow to automatically populate the template taking input from XML files. In other words: you can add special tags in your template, using standard XPath syntax, which refer to data contained in an external XML file. By this way, no need to programmatically populate this block of data: JDynamiTe parser automatically does it for you. Find several examples here.
  • JDynamiTe analyser is highly customizable: any syntax can be defined (using regular expressions) for these tags. For example, with HTML template document (default syntax), the tags are enclosed within HTML comments.
  • JDynamiTe enables template reuse (input template reading once for multiple dynamic generations).
  • It also enables Dynamic Elements nesting (e.g. to create list of lists).
  • An optional tag is available that allows inserting "ignored blocks" in the template document. You can insert in your template "real" data into this special kind of blocks, simulating a more realistic rendering, which can be a useful working document for designers. These block contents are completely ignored during template parsing.
  • Since JDynamite 1.2, the list of template document "Variable keys" is programmatically available.
  • A little bit of history: part of JDynamiTe was initially based on the same concept as that of "PHP FastTemplate" (a popular PHP extension mainly used in the domain of Web HTML pages creation).

JDynTool: it does the job for you...

Since the release 2.0, JDynamiTe project provides a "magic" tool: JDynTool.
JDynTool is based on JDynamiTe package, allowing to use JDynamiTe template files by two very simple ways:
  • by command line invocation: no java code is needed (this is a "stand-alone" mode),
  • or by JDynTool class "run" method call: only few lines of code in your java application.
The interest of JDynTool is to automatically process "XML Dynamic Elements" blocks defined in the template document and then to generate the output result file, taking input from XML files referenced into these XML blocks.
Several examples (Table of Content Generator from "Eclipse XML toc" file, XML RSS Reader ...) provided with JDynamiTe project use the simplicity and powerful of JDynTool.
More details in JDynTool documentation and several JDynTool use cases here.

Benefits

  • JDynamiTe allows to separates presentation level (HTML, XML, or any textual description) from the content generation code. These two domains do not required the same skills!
  • In the case of HTML generation, for example, JDynamiTe template files can be designed with your preferred HTML builder, and by a "true" HTML designer. HTML designers do not have to know JSP, Java, or any new template language.
  • An efficient and fast way to create a template is to start from an existing document close to the file you want to generate and identifying the parts which should be "dynamic data", then replacing these parts by "Dynamic Element blocks". Note: you can also keep existing data by enclosing them into "Ignored block" tags, in order to simulate a more realistic rendering.

Requirements/dependencies

  • JRE 1.5 or higher.
  • To run JDynTool: "java-getopt-1.0.14.jar", included in JDynamiTe distribution.
    "java-getopt" is a Java port of GNU getopt, provided by Aaron M. Renn (thanks to him and to developers who support this package).
  • To run JSP and Servlets examples: a Servlet container such as Apache Tomcat ("javax.servlet" package, required by JDynamiTe Servlets examples Java classes, can be found in "apache-tomcat/lib/servlet-api.jar").
Note: JDynamiTe is a "lightweight" package: less than 150 kb for jdynamite.jar

Installation

  • Extract "jdynamite.jar" and "java-getopt-1.0.14.jar" from the distribution package and copy these jar files into a directory referenced by your Java "classpath".
  • Note that all examples (classes, templates ...) as well as whole documentation (javadoc, examples description) are included into JDynamiTe distribution.
  • Concerning JSP and Servlets examples: If you want to run these examples in real situation, you have to deploy them into a Servlets container. With Apache Tomcat, for example, copy the JSP-Servlets/JDynamiTeExamples directory into the apache_tomcat_install_dir/webapps directory.

Download

Download last JDynamiTe version from JDynamiTe SourceForge domain.

Documentation

News

JDynamiTe 2.0 - April 2014

Here is the main news since the previous release (version 1.2):
  • There is a new kind of Dynamic Element: "XML Dynamic Elements" allow to automatically populate the template taking input from XML files. In other words: you can add special tags in your template, using standard XPath syntax, which refer to data contained in an external XML file. By this way, no need to programmatically populate this block of data: JDynamiTe parser automatically does it for you.
  • Find several examples in the new dedicated JDynamiTe examples page, as well as updated Javadoc here.
  • JDynTool is now available: based on JDynamiTe package, this tool allows to use JDynamiTe template files by two very simple ways, including command line invocation. More details here.
  • Some improvements and new methods added, taking into account users feedback and requests.