Help

Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

There are several features in JSF which require one component to reference another component. There are slight variations in the algorithm used to find the related component. There are two concerns to address:

  1. consistency across implementations
  2. performance

Additionally, the syntax for component referencing should be made more intuitive and flexible.

Current implementations

Let's consider how the for attribute on the h:outputLabel and h:message components is handled.

MyFaces does the following:

  • Calls findComponent() using the outputLabel/message component as the base component.
  • If a component is found, return the id.
  • If the component is found, attempt to construct an id manually (via string manipulation).

This behavior is identical to the f:ajax execute/render id behavior, at least in the case where the id corresponds to a component that can be found in the component tree.

Mojarra starts off similar:

- Calls findComponent() using the outputLabel/message component as the base component.

For cases where a relative id is specified in the same naming container, or an absolute id is specified, both f:ajax and h:outputLabel behave the same in Mojarra. However, in the event that the findComponent() call does not find the component, Mojarra then goes on to:

  • Walk up the ancestor chain.
  • For each component in the ancestor chain, call findComponent().
  • If the root is reached and a matching component hasn't been found, recursively walk over the entire component tree looking for NamingContainers, and call findComponent() on each NamingContainer.

That's a lot of component tree walking!

Changes

Here's what we need:

  1. A spec clarification regarding the algorithm for finding a related component
  2. Reduce the number of calls to findCompoennt()
  3. Provide a way to explicitly address components in ancestor naming containers, either :: prefix to pop one level in the hierarchy or use an XPath or jQuery syntax
  4. Reconsider whether f:ajax needs to perform id processing/encoding at render time