Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Tag Conversion Design"

(Archetype-driven Transforms)
(Archetype-driven Transforms)
Line 38: Line 38:
  
 
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 JSF are shown below:
 
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 JSF are shown below:
 +
 +
[[Image:Archetypes.png]]
 +
 +
===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, let's say it is called "c:MyTextBox" is identified as implementing the "Input", "IEditableValueHolder" and "IValidation.date" (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:
 +
 +
<pre>
 +
<MyTextBox value="Foo"/>
 +
 +
into
 +
 +
<input type="text>Foo</input>
 +
</pre>
 +
 +
since it's 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.  The fact that there is a validator attached may not come into play in the rendering of the HTML, but can passed along in DT meta-information about the rendered tag to support editing and validation tooling.

Revision as of 18:29, 8 January 2007

Overview

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 change.

The design-time 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 a ITagConverter.

One or more factories is consulted to construct 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 one-to-one 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 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:

Tag conversion factories create ITagConverters based on the type of tag that exists in the source model.

TagConverter.png

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 transformer class in the form of 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 rendering.

Before consulting ITagTransformer for the tag transformation, IOutputRenderer calls decorate() on each of its ITransformDecorator's to put additional logic into the transform. This mechanism is pluggable and can allow multiple sources of knowledge about the rendering to be injected by sources such as meta-data, tag instantiators, 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.

TagConverterFactory.png

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 JSF are shown below:

Archetypes.png

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, let's say it is called "c:MyTextBox" is identified as implementing the "Input", "IEditableValueHolder" and "IValidation.date" (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"/>

into 

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

since it's 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. The fact that there is a validator attached may not come into play in the rendering of the HTML, but can passed along in DT meta-information about the rendered tag to support editing and validation tooling.

Back to the top