org.apache.myfaces.trinidad.component
Interface FlattenedComponent

All Known Implementing Classes:
CoreTable, UIXGroup, UIXIterator, UIXSwitcher, UIXTable

public interface FlattenedComponent

Interface implemented by Components that don't render any content themselves but rather set up context before asking their children to render themselves. Implementing this interface enables Renderers for components that contain instances of the FlattenedComponents to visit each descendant in a flattened view of their children, recursively including any FlattenedComponent treating all of these descendants as direct children.

A good indicator that a component should implement FlattenedComponent is that the component doesn't delegate to a Renderer, but rather renders itself.

See Also:
ComponentProcessor, UIXComponent.processFlattenedChildren(FacesContext, ComponentProcessingContext, ComponentProcessor, UIComponent, Object), UIXComponent.processFlattenedChildren(FacesContext, ComponentProcessingContext, ComponentProcessor, Iterable, Object)

Method Summary
 boolean isFlatteningChildren(javax.faces.context.FacesContext context)
          Returns true if this FlattenedComponent is currently flattening its children.
<S> boolean
processFlattenedChildren(javax.faces.context.FacesContext context, ComponentProcessingContext cpContext, ComponentProcessor<S> childProcessor, S callbackContext)
          Set up the component context, process all of the renderable children of this component, and the restore the previous context, returning true if any of the children were processed.
 

Method Detail

processFlattenedChildren

<S> boolean processFlattenedChildren(javax.faces.context.FacesContext context,
                                     ComponentProcessingContext cpContext,
                                     ComponentProcessor<S> childProcessor,
                                     S callbackContext)
                                 throws IOException
Set up the component context, process all of the renderable children of this component, and the restore the previous context, returning true if any of the children were processed.

The context set up and tear down to perform is identical to that which the component would perform when handling rendering or implementing invokeOnComponent

To handle actually processing the children, the component will typically delegate to one of the two UIXComponent.processFlattenedChildren helpers. If the component only processes a single child, as UIXSwitcher does, it will call the version taking a single child as the argument. If it processes all of its children as UIXIterator and UIXGroup do, it will call getChildren and pass the List<UIComponent> to the version accepting an Iterable<UIComponent>.

This method should only be called if FlattenedComponent.isFlatteningChildren returns true. If called when FlattenedComponent.isFlatteningChildren is false the behavior is undefined and the implementation may throw an IllegalStateException.

This method may only be called when the FlattenedComponent is in the correct context to process itself.

Parameters:
context - Current FacesContext
cpContext - ComponentProcesingContext represetning the current child iteration state
childProcessor - ComponentProcessor to call for each flattened child
callbackContext - childProcessor-specific context to be passed on each call to the childProcessor
Returns:
true if this FlattenedComponent actually processed any children
Throws:
IOException - if an error occurs while processing children
IllegalStateException - if called when isFlatteningChildren() is false.
See Also:
UIXComponent.processFlattenedChildren(FacesContext, ComponentProcessingContext, ComponentProcessor, UIComponent, Object), UIXComponent.processFlattenedChildren(FacesContext, ComponentProcessingContext, ComponentProcessor, Iterable, Object), isFlatteningChildren(javax.faces.context.FacesContext)

isFlatteningChildren

boolean isFlatteningChildren(javax.faces.context.FacesContext context)
Returns true if this FlattenedComponent is currently flattening its children. This allows a FlattenedComponent instance to flatten or not flatten its children as it sees fit.

It is illegal to call processFlattenedChildren on a FlattenedComponent that has returned false from isFlatteningChildren.

Parameters:
context - FacesContext
Returns:
true if this FlattenedComponent is currently flattening its children
See Also:
processFlattenedChildren(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.component.ComponentProcessingContext, org.apache.myfaces.trinidad.component.ComponentProcessor, S)


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.