Skip to main content
Jump to: navigation, search

Tag Conversion Design


This design note describes a proposed design for model view conversion from JSP/JSF tags to HTML in the Visual Page Designer. This document should be considered tentative and highly subject to change.

The design-time WYSIWYG render engine for the Visual Page Designer (VPD) is an HTML/CSS visual renderer. It relies on a transformed view of the JSP page model that approximates the HTML/CSS output that the real runtime servlet would generate to render a page. To accomplish the conversion of the design time model, the VPD uses the concept of an ITagConverter.

One or more factories are consulted to construct an ITagConverter for each tag found in the source document. For each tag that has an ITagConverter constructed, transforming of the tag to the corresponding HTML is delegated.

Tag Converters

Tag converters are transformative adapters that create mappings from source model tags to renderable HTML elements. Each converter may be thought of as a mapping function, f where:

f: Tjsp -> Thtml

where T is the set of all valid tags, Tjsp is the the subset of T containing only valid JSP source document tags and Thtml is the subset of T containing only valid HTML 4.01 tags. f is not guaranteed to be strictly bijective. However, given a fixed Tjsp, Gjsp (i.e. a specific JSP source document), the set Gf (the resulting HTML document) will always have a bijective relationship to Gjsp. Thus, for any resulting HTML rendered tag, a reverse mapping to the source JSP tag should always be possible. Although a possible exception may occur with tags that use the Composition archetypes (see Archetypes below), since composed objects may involve generating multiple sibling HTML tags for a single JSP/JSF tag (for example, a tabbed panel).

Transformation-based Tag Converters

While an extension-point based system is provided (see Factories below) for creation of customized tag converters, the preferred method of tag conversion is to create transformation mappings through the use of meta-data. In this scenario, the following class structure is provided as the "workhorse" tag converter for doing most model adaption:


The DTTagConverter implements that main logic for meta-data driven conversion. The converter has (possibly pluggable) IOutputRenderer that does the work of converting an input tag into a basic HTML output. To do this, the IOutputRenderer has a transformer class in the form of an ITagTransformer. The ITagTransformer uses a map of ITransformStrategy's that are used to perform transformations on source tags to produce an ever-more exact approximation of the final HTML for design time rendering.

Before consulting ITagTransformer for the tag transformation, IOutputRenderer calls decorate() on each of its ITransformDecorator's to put additional knowledge about the tag into the transform. This mechanism is pluggable and can allow multiple sources of knowledge about the rendering to be injected from sources such as meta-data, tag instantiators, third-party customizers and (some day) a mock servlet mechanism.

Tag Conversion Factories

Tag conversion factories are used to create and configure tag converters based on the properties of the tag, the state of the system and other possible information contributed by third-parties.


The ComposedTagConversionFactory composes multiple IConverterFactory's and is the single source used by the HTML renderer to determine what ITagConverter should be used for each tag. In most cases, the SystemTagConverterFactory will be used for all tags. Providers of component tooling and meta-data may override this with their own factory through an extension point.

Archetype-driven Transforms

The majority of the JSP->HTML transformation strategy is based on the idea of Archetypes. Archetypes are defined for each of the model, view and controller that is modelled at design time for a JSP/JSF document. A selection of the most common ones needed for JSF are shown below:


How Transformation Uses Archetypes

Archetype-driven transformers use common mappings from archetypal properties to aspects of the design-time rendering and editing behaviour. For example, if a tag called "c:MyTextBox" is identified as implementing the "Input", "IEditableValueHolder" and "" (here "." is a notational cheat for a validator that ensures the value is a "date"), then in the absence of more specific information (such as might be derived from a mock servlet), an ITransformStrategy may decide to convert:

<MyTextBox value="Foo"/>


<input type="text>Foo</input>

since its common mapping would tell it that an "Input" archetype should create a input textbox, the "IEditableValueHolder" says the the box is editable and that "value" is its value (probably through further meta-data hinting). The fact that there is a validator attached may not come into play in the rendering of the HTML, but can be passed along in DT meta-information about the rendered tag to support editing and validation tooling.

Back to the top