Kiss My App

Sunday, May 22, 2005

Making Facelets mimic Tapestry

Facelets has one very easy way of making any component or any tag replace an existing HTML element. You can, for example, do something like this:

<html xmlns=""
<span id="intact" jsfc="ui:remove">
This Text Will Be Removed.

With Facelets, id's are left in tact, and at compile time, the 'jsfc' attribute tells the compiler to instead handle this element as a ui:remove. The same could be done with your UIComponents (inputText, commandButton, etc), along with JSTL tags such as c:if or c:forEach.

Currently, c:forEach doesn't decorate-- meaning if you turn a <tr> tag into a c:forEach, then the <tr> will be omitted from the output. Having c:forEach instead decorate, keeping <tr> intact wouldn't be difficult at all and would simply require extending the ForEachHandler included with Facelets to write out some stuff before and after calling super.apply(FaceletContext,UIComponent).

One drawback/benefit of Facelets is that expressions can be embeded within the page and don't require an element to capture their output. So things like this can be done:

<span class="highlight">#{login.error}</span>

In this case, the element span would be left intact as the designer created, and the #{login.error} would be evaluated to the rendered output.

Great care has been given to handling 'template' text where the content isn't a special tag, but may include dynamic parts. This has been highly optimized to work in conjuction with JSF's lifecycle.

More samples to come soon--

Anyone else going to JavaOne also this year?


Post a Comment

<< Home