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:
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
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:
In this case, the element
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?
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets">
...
<span id="intact" jsfc="ui:remove">
This Text Will Be Removed.
</span>
....
</html>
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?
2 Comments:
RE: JavaOne - I'll be there. ;-)
By Matt Raible, at 12:53 AM
tr we can leave inact, wrapping it
in tbody tag with jfc="c:forEach" or ui:remove
Because table support many tbody (which may be stripped by facelets)
By Anonymous, at 12:33 PM
Post a Comment
<< Home