EchoPoint
1.0

echopoint.layout
Class HtmlTemplateLayoutManager

java.lang.Object
  extended byechopoint.layout.AbstractLayoutManager
      extended byechopoint.layout.HtmlTemplateLayoutManager
All Implemented Interfaces:
ComponentMapper, LayoutManager, PropertyManagerOwner, java.io.Serializable

public class HtmlTemplateLayoutManager
extends AbstractLayoutManager
implements ComponentMapper, PropertyManagerOwner

The HtmlTemplateLayoutManager class can be used as a layout manager that will use an HTML template as a basis to render other Components within it.

The generalised form of the template looks something like the following :

 <HTML><BODY>
 Name : <COMPONENT NAME="PERSON"><COMPONENT><BR>
 Address: <COMPONENT NAME="ADDRESS" ICON="address.gif"><COMPONENT><BR>
 Phone : <COMPONENT NAME="PHONE"><COMPONENT><BR>
 </BODY></HTML>
 

The COMPONENT tags will be subsituted with the real components that has been previously added via the addLayoutComponent() method. The components are matched via the constraint name and the templated attribute name="x".

 templateLayout.addLayoutComponent(new TextField("Name"), 	"PERSON");
 templateLayout.addLayoutComponent(new TextField("Address"), 	"ADDRESS");
 templateLayout.addLayoutComponent(new TextField("Phone"), 	"PHONE");
 

Note : Components will NOT be created if they have NOT been added to the HtmlTemplateLayoutManager. The template will, by design, fail to render them, but will instead insert garish HTML noting their absence.

You can turn this dire warning off via the setLoudErrorsUsed(false);

Parsing is done via a two pass process. The first pass runs through all the template content and marks the positions of the handled tags.

The second pass will then copy static content up until each remembered tag position. It will then invoke the tag handler that allows the component to generate is content. Then the rest of the static content is copied until another active tag position is reached and so on.

All DataSources have their last modified time checked. If they are up to date then only the second pass parse will be performed, and hence rendering time is reduced.

The content of Files and URLs are cached internally if they are smaller than getFileCacheSizeLimit() and hence will execute very fast the next time they are rendered.

The attributes within the HTML tags are then applied to the Component before it is displayed, if there is a PropertyManager available that understands the tag attributes and they have not already been set.

These attributes are only applied to the contained Components once for a given DataSource. If you use the same DataSource on another HtmlTemplateLayoutManager, then the tag attributes will be set into the components that the new layout manager contains. However a compilation of the DataSource will not occur unless it is out of date.

You can force a explcit compilation to occur before the template is displayed by adding all components and then calling the compileDataSource method.

The current list of tags parsed and handled by PropertyManagers are as follows:

All tags have the following attributes which can be used to control the appearance of the Components :