Home > Web development > JSF2: Rendering facets inside nested composite components

JSF2: Rendering facets inside nested composite components

January 27th, 2011 Leave a comment Go to comments

…is not supported, as I just found out:

<composite:interface>
	<composite:facet name="basketContent"/>
</composite:interface>

<composite:implementation>		 
	<mycomponents:box title="Shopping basket">
		<composite:renderFacet name="basketContent"/>
	</mycomponents:box>
</composite:implementation>


So we have got an outer component (let’s call it shopping-basket), and an inner component named box. Now, the basketContent facet is never rendered. Why? This is because the composite component renderer (com.sun.faces.renderkit.html_basic.CompositeFacetRenderer) only searches the current composite component’s facets for the given facet name. So, it searches for a facet called basketContent in the box component, instead of the outer shopping-basket component. The following code fragment works:

<composite:implementation>		 
	<composite:renderFacet name="basketContent"/>

	<mycomponents:box title="Shopping basket">
	</mycomponents:box>
</composite:implementation>

But this, of course, puts the basket content outside of the box, which is not what I want. That’s a bummer. Seems like another flaw in the JSF 2.0 specification… and I am not the only one with this problem.

Categories: Web development Tags:
  1. tommy
    September 30th, 2011 at 09:07 | #1
    Reply | Quote
    VA:F [1.9.20_1166]
    0

    I added an issue to Mojarra’s bug database.

    http://java.net/jira/browse/JAVASERVERFACES-2219

    Feel free to vote for it that it will be implemented earlier.

  1. No trackbacks yet.
You must be logged in to post a comment.