webtier@glassfish.java.net

Re: [webtier] JSF2: problem using custom component with facets

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Wed, 19 Aug 2009 08:44:10 -0700

On 8/19/09 5:18 AM, webtier_at_javadesktop.org wrote:
> I'm unsure how to use facets in custom components. If I'm interpreting the spec correctly, you should declare the available facets in the<composite:interface> section of the component.
>
> [code]
> <composite:interface>
> <composite:facet name="test"/>
> </composite:interface>
> [/code]
>
> And then use the<insertFacet> tag in the<composite:implementation> section.
>
> [code]
> <composite:implementation>
> <h:panelGroup>
> <composite:insertFacet name="test"/>
> </h:panelGroup>
> </composite:implementation>
> [/code]
>
> However, when I try to use this component with a facet, the facet is not shown in the output.
>
> [code]
> <ez:comp>
> <f:facet name="test">
> <h:outputText value="foo"/>
> </f:facet>
> </ez:comp>
> [/code]
>
> Is there more to it?
>

You should check the documentation for the component you're attaching a
facet to. If the facet you're
inserting isn't in the set of facets supported by the component, you
shouldn't expect it to be rendered.

That having been said, if you want to have the content of a facet
rendered no matter if the component
supports it or not (this probably isn't desirable with certain
components), you can use the
composite:renderFacet [2] action.

Here is the documentation for the standard components included in 2.0 [1].

[1]
https://javaserverfaces.dev.java.net/nonav/docs/2.0/pdldocs/facelets/index.html
[2]
https://javaserverfaces.dev.java.net/nonav/docs/2.0/pdldocs/facelets/composite/renderFacet.html
> [Message sent by forum member 'janderssn' (janderssn)]
>
> http://forums.java.net/jive/thread.jspa?messageID=361148
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: webtier-unsubscribe_at_glassfish.dev.java.net
> For additional commands, e-mail: webtier-help_at_glassfish.dev.java.net
>
>