org.apache.myfaces.trinidad.component
Class UIXSwitcher

java.lang.Object
  extended by javax.faces.component.UIComponent
      extended by org.apache.myfaces.trinidad.component.UIXComponent
          extended by org.apache.myfaces.trinidad.component.UIXComponentBase
              extended by org.apache.myfaces.trinidad.component.UIXSwitcher
All Implemented Interfaces:
EventListener, javax.faces.component.PartialStateHolder, javax.faces.component.StateHolder, javax.faces.event.ComponentSystemEventListener, javax.faces.event.FacesListener, javax.faces.event.SystemEventListenerHolder, FlattenedComponent

public class UIXSwitcher
extends UIXComponentBase
implements FlattenedComponent

The switcher component dynamically decides which facet component should be rendered. It has two properties. The switcher will render the facet matching "facetName"; however, if no such facet exists (or "facetName" is null), and "defaultFacet" has been set, then that facet will be used instead. (It's possible to achieve this same functionality by using a panelGroup and binding the "rendered" property of each child, but this component can be simpler. Ordinary children of the switcher component are not rendered at all.)

Events:

Type Phases Description
org.apache.myfaces.trinidad.event.AttributeChangeEvent Invoke
Application
Apply
Request
Values
Event delivered to describe an attribute change. Attribute change events are not delivered for any programmatic change to a property. They are only delivered when a renderer changes a property without the application's specific request. An example of an attribute change event might include the width of a column that supported client-side resizing.


Field Summary
static String COMPONENT_FAMILY
           
static String COMPONENT_TYPE
           
static PropertyKey DEFAULT_FACET_KEY
           
static PropertyKey FACET_NAME_KEY
           
static FacesBean.Type TYPE
           
 
Fields inherited from class org.apache.myfaces.trinidad.component.UIXComponentBase
BINDING_KEY, ID_KEY, RENDERED_KEY, RENDERER_TYPE_KEY, TRANSIENT_KEY
 
Fields inherited from class javax.faces.component.UIComponent
BEANINFO_KEY, bindings, COMPOSITE_COMPONENT_TYPE_KEY, COMPOSITE_FACET_NAME, CURRENT_COMPONENT, CURRENT_COMPOSITE_COMPONENT, FACETS_KEY, VIEW_LOCATION_KEY
 
Constructor Summary
  UIXSwitcher()
          Construct an instance of the UIXSwitcher.
protected UIXSwitcher(String rendererType)
          Construct an instance of the UIXSwitcher.
 
Method Summary
 void encodeChildren(javax.faces.context.FacesContext context)
          Only render the currently active facet.
protected  FacesBean.Type getBeanType()
           
 String getDefaultFacet()
          Gets the name of the facet to render and process if "facetName" is null or otherwise does not refer to an existing facet.
 String getFacetName()
          Gets the name of the facet to render and process.
 String getFamily()
           
protected  Iterator<javax.faces.component.UIComponent> getRenderedFacetsAndChildren(javax.faces.context.FacesContext facesContext)
          Specifies what facets and children components should be processed as rendered for life-cycle methods.
 boolean getRendersChildren()
          Override to return true.
 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)
          Processes the selected switcher facet
 void setDefaultFacet(String defaultFacet)
          Sets the name of the facet to render and process if "facetName" is null or otherwise does not refer to an existing facet.
 void setFacetName(String facetName)
          Sets the name of the facet to render and process.
 
Methods inherited from class org.apache.myfaces.trinidad.component.UIXComponentBase
adaptMethodBinding, addAttributeChange, addAttributeChangeListener, addClientBehavior, addComponentChange, addComponentChange, addFacesListener, broadcast, broadcastToMethodBinding, broadcastToMethodExpression, clearInitialState, createFacesBean, decode, decodeChildren, decodeChildrenImpl, encodeBegin, encodeEnd, findComponent, getAttributeChangeListener, getAttributeChangeListeners, getAttributes, getBooleanProperty, getChildCount, getChildren, getClientBehaviors, getClientId, getContainerClientId, getDefaultEventName, getFacesBean, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacetNames, getFacets, getFacetsAndChildren, getId, getIntProperty, getLifecycleRenderer, getListenersForEventClass, getParent, getProperty, getPropertyKey, getRenderer, getRendererType, getValueBinding, getValueExpression, initialStateMarked, invokeOnChildrenComponents, invokeOnComponent, invokeOnNamingContainerComponent, isRendered, isTransient, markInitialState, processDecodes, processRestoreState, processSaveState, processUpdates, processValidators, queueEvent, removeAttributeChangeListener, removeFacesListener, restoreState, satisfiesPartialTrigger, saveState, setAttributeChangeListener, setAttributeChangeListener, setBooleanProperty, setId, setIntProperty, setParent, setProperty, setRendered, setRendererType, setTransient, setupFlattenedChildrenContext, setupFlattenedContext, setValueBinding, setValueExpression, subscribeToEvent, tearDownFlattenedChildrenContext, tearDownFlattenedContext, toString, unsubscribeFromEvent, updateChildren, updateChildrenImpl, validateChildren, validateChildrenImpl
 
Methods inherited from class org.apache.myfaces.trinidad.component.UIXComponent
addPartialTarget, clearCachedClientIds, clearCachedClientIds, encodeFlattenedChild, encodeFlattenedChildren, getLogicalParent, getLogicalParent, getStateHelper, getStateHelper, isVisitable, partialEncodeVisit, processFlattenedChildren, processFlattenedChildren, processFlattenedChildren, processFlattenedChildren, setPartialTarget, setupChildrenEncodingContext, setupChildrenVisitingContext, setupEncodingContext, setUpEncodingContext, setupVisitingContext, tearDownChildrenEncodingContext, tearDownChildrenVisitingContext, tearDownEncodingContext, tearDownVisitingContext, visitAllChildren, visitChildren, visitChildren, visitTree, visitTree
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getClientId, getCompositeComponentParent, getContainerClientId, getCurrentComponent, getCurrentCompositeComponent, getNamingContainer, getResourceBundleMap, isCompositeComponent, isInView, popComponentFromEL, processEvent, pushComponentToEL, setInView
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE

public static final FacesBean.Type TYPE

FACET_NAME_KEY

public static final PropertyKey FACET_NAME_KEY

DEFAULT_FACET_KEY

public static final PropertyKey DEFAULT_FACET_KEY

COMPONENT_FAMILY

public static final String COMPONENT_FAMILY
See Also:
Constant Field Values

COMPONENT_TYPE

public static final String COMPONENT_TYPE
See Also:
Constant Field Values
Constructor Detail

UIXSwitcher

public UIXSwitcher()
Construct an instance of the UIXSwitcher.


UIXSwitcher

protected UIXSwitcher(String rendererType)
Construct an instance of the UIXSwitcher.

Method Detail

processFlattenedChildren

public <S> boolean processFlattenedChildren(javax.faces.context.FacesContext context,
                                            ComponentProcessingContext cpContext,
                                            ComponentProcessor<S> childProcessor,
                                            S callbackContext)
                                 throws IOException
Processes the selected switcher facet

Specified by:
processFlattenedChildren in interface FlattenedComponent
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
See Also:
UIXComponent.processFlattenedChildren(FacesContext, ComponentProcessingContext, ComponentProcessor, UIComponent, Object), UIXComponent.processFlattenedChildren(FacesContext, ComponentProcessingContext, ComponentProcessor, Iterable, Object), FlattenedComponent.isFlatteningChildren(javax.faces.context.FacesContext)

isFlatteningChildren

public boolean isFlatteningChildren(javax.faces.context.FacesContext context)
Returns true if this FlattenedComponent is currently flattening its children

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

encodeChildren

public void encodeChildren(javax.faces.context.FacesContext context)
                    throws IOException
Only render the currently active facet.

Overrides:
encodeChildren in class UIXComponentBase
Throws:
IOException

getRendersChildren

public boolean getRendersChildren()
Override to return true.

Overrides:
getRendersChildren in class UIXComponentBase

getRenderedFacetsAndChildren

protected Iterator<javax.faces.component.UIComponent> getRenderedFacetsAndChildren(javax.faces.context.FacesContext facesContext)
Description copied from class: UIXComponent
Specifies what facets and children components should be processed as rendered for life-cycle methods. Any components not returned will not be processed during methods such as decoding, validating, updating the model, rendered-only tree visiting, etc.

Overrides:
getRenderedFacetsAndChildren in class UIXComponentBase
Parameters:
facesContext - the facesContext
Returns:
An iterator of components to process. Must not return null (return an empty iterator if no children components should be processed).

getFacetName

public final String getFacetName()
Gets the name of the facet to render and process.

Returns:
the new facetName value

setFacetName

public final void setFacetName(String facetName)
Sets the name of the facet to render and process.

Parameters:
facetName - the new facetName value

getDefaultFacet

public final String getDefaultFacet()
Gets the name of the facet to render and process if "facetName" is null or otherwise does not refer to an existing facet.

Returns:
the new defaultFacet value

setDefaultFacet

public final void setDefaultFacet(String defaultFacet)
Sets the name of the facet to render and process if "facetName" is null or otherwise does not refer to an existing facet.

Parameters:
defaultFacet - the new defaultFacet value

getFamily

public String getFamily()
Specified by:
getFamily in class UIXComponentBase

getBeanType

protected FacesBean.Type getBeanType()
Overrides:
getBeanType in class UIXComponentBase


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