Skip to main content

JSF2: Problems using buttons in facets to composite components

Please note these forums are being decommissioned and use the new and improved forums at
2 replies [Last post]
Joined: 2011-08-02


i want to add buttons via facets to a composite component. The component renders a datatable and i want to pass the row entity to the action method of the buttons as parameter. Unfortunately the passed in parameter is always NULL. If i use the datatable and the buttons directly, without composite component stuff, everything works as expected.
Is it not possible to set buttons via facets to composite components?

  <composite:attribute name="list" />
  <composite:facet name="rowButton" />


  <p:dataTable id="customer" var="customer" value="#{cc.attrs.list}">
      <composite:renderFacet name="rowButton" />

      <customer:list list="#{customerControllerBean.list}">
        <f:facet name="rowButton">
          <h:commandButton value="#{msg.deleteButtonLabel}"
        action="#{customerControllerBean.delete(customer)}" />

          <h:commandButton value="#{msg.deleteButtonLabel}" action="#{customerControllerBean.deleteCustomer}">
        <f:setPropertyActionListener target="#{customerControllerBean.customer}" value="#{customer}"/>

          <h:button outcome="customerdetail.jsf?id=#{}"
        value="#{msg.editButtonLabel}" />

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Joined: 2011-03-28

Edit: I think f:facet can only have one child, can you try wrapping everything inside the facet in a panelGroup. There are lots of people having problems with this, with no clear solution that I've seen. Although a great concept I usually hit a brick wall with composite components when trying to do anything beyond the very simple, which tends to outweigh the potential benefits.

Original answer:

I'm pretty rusty on composite components but can you try wrapping everything inside the composite:implementation in:

  <div id="#{cc.clientId}">

I vaguely recollect issues with generating client ids in the generated code because the composite needs a naming container. You could use a <span> instead of a <div>, or a panelGroup with or without layout="block".

This is a long shot!

Joined: 2011-08-02

thanks for the hints. i tried with div, span and panelGroup. i can see that the ids of the datatable and the buttons change, but unfortunately the passed in object is still null.
from stack overflow i got answer that composite components have logs of bugs and i should switch to templating. and i switchd to a template and it really works.