- Clay grafts a sub tree into an existing tree. But this is done by adding the clay to main tree and the clay component adds the sub tree as its child.
For example:
When using clay to load a template, the clay tag is used in jsp.
<clay:clay id="abc" jsfid="templatename">
</clay:clay>
The execution of this tag adds clay component to the view tree and while rendering, the clay component builds the sub tree from the template and adds it as a child.
The tree is as follows:
Viewroot
|__clay
| |__template contents
|
|__other page component..
- It cannot be used to load a template for a container.
For example:
When using datatable normally the code looks as follows:
<t:datatable attributes…>
<h:column>
Column contents
</h:column>
<h:column>
Column contents
</h:column>
</t:datatable>
The tree is as follows:
Datatable
|__column
| |__column contents
|
|__column
|__column contents
As there are many attributes that need to be definedon the datatable, we want to create a template. So with clay it will be as follows:
<clay:clay id="mydatalist" jsfid="mytable">
<h:column>
Column contents
</h:column>
<h:column>
Column contents
</h:column>
</clay:clay>
But what happens is the tree will be as follows:
Clay
|__datatable
|
|__column
| |__column contents
|
|__column
|__column contents
The template contents become children of clay as well as the components inside clay tag body also become its children.
- column definition has lots of repetitive code.
For example:
<datatable>
<column>
<facet name="header">
Header contents
</facet>
Column contents
</column>
<column>
<facet name="header">
Header contents
</facet>
Column contents
</column>
<column>
<facet name="header">
Header contents
</facet>
Column contents
</column>
</datatable>
To avoid this we wanted to create template for column.
With the template the code is as follows:
<datatable>
<clay jsfid="column template" other parameters…>
<clay jsfid="column template" other parameters…>
</datatable>
But based on point 1 above the tree is as follows:
Datatable
|__clay
| |__column
|
|__clay
|__column
This tree is fine, but the datatable component according to the spec will only render a child if it's a column. But in this column is hidden under clay and hence nothing is rendered.(clay components are immediate children of datatable)
Hi,
For the first thing, FacesContext.getCurrentInstance.getApplication().createComponent(String type) method will do the job.
For the second thing, facelets is another solution for templating and composition from templates.
Cagatay
On 6/16/06, Phanidhar Adusumilli <[EMAIL PROTECTED] > wrote:The class UIComponentTag has a method createComponentInstance. This method is private. If this method is protected one can override this and provide alternative creation mechanism.One example can be, clay api can be used to create a component and its children from a template. Thus using these templates will make JSP code simpler.I would appreciate others opinion on this.

