webtier@glassfish.java.net

Re: f:actionListener for composite bug?

From: Ed Burns <Ed.Burns_at_Sun.COM>
Date: Tue, 24 Feb 2009 07:55:39 -0800

>>>>> On Sun, 22 Feb 2009 18:07:37 -0800, Ed Burns <Ed.Burns_at_Sun.COM> said:

>>>>> On Wed, 11 Feb 2009 09:05:44 -0800, Ed Burns <ed.burns_at_sun.com> said:
>>>>> On Tue, 10 Feb 2009 17:43:03 -0700, David Geary <david.mark.geary_at_gmail.com> said:
DG> Hi Ed,
DG> I'm having the same problem as these guys:
DG> <http://forums.java.net/jive/thread.jspa?messageID=320051>. I have an
DG> f:actionListener on a composite component, and the listener is never
DG> called. I tried both the binding and type attributes, but neither
DG> works.

Actually, Ryan suggested a more appropriate fix, which I've documented
in the tlddocs for composite:interface:

Naming containers within composite components

Composite components are themselves naming containers so that any
possible id conflicts between inner components and components in the
using page are avoided. However, special care must be taken when using
naming containers in the <composite:implementation> section. In such
cases the ?targets? attribute must be used with a clientId relative to
the top level component to expose any attached object targets to the
using page. For example:

Using page

<ez:loginButton>
  <f:actionListener for="loginAction" />
</ez:loginButton>
loginButton.xhtml

<composite:interface>
  <composite:actionSource name="button" targets="form:button" />
</composite:interface>
 
<composite:implementation>
 
  <h:form id="form">
    <h:commandButton id="button" value="Submit" />
  </h:form>
</composite:implementation>

Because the button on line 8 resides within a form, it must be referred
to using the "targets" attribute on line 2. Simply using the "name"
attribute is not sufficient because "name" is always interprented as a
simple component id, whereas the elements of the "targets" attribute are
interpreted as client ids, relative to the top level component.


-- 
| ed.burns_at_sun.com  | office: 408 884 9519 OR x31640
| homepage:         | http://ridingthecrest.com/