Friday, July 13, 2012

Programmatic Facelet:Composite Component with Facet, API approach

In my blast post, I demonstrated how you can create a composite component with facet in it.  I used a temporary file to do the work. In this post, I use a purely API approach.  Suppose I have
I can do it like this

 First, I create the composite component.

UIComponen  compositeComponent=...

Then I create myfacet component
UIComponent fragment=....

 Finally, I attach the created fragment as facet to composite component.
compositeComponent.getFacets().put("firstfacet", fragment);

The advantage of this apporach: you do not need to worry about temporary file generation and path translation for fragment file.
The disadvantage of this approach: for each facet NAME, you can only attach one component.

No comments:

Post a Comment