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:
StateHolder, 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 events 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
bindings
 
Constructor Summary
  UIXSwitcher()
          Construct an instance of the UIXSwitcher.
protected UIXSwitcher(String rendererType)
          Construct an instance of the UIXSwitcher.
 
Method Summary
 void encodeChildren(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()
           
 boolean getRendersChildren()
          Override to return true.
 boolean isFlatteningChildren(FacesContext context)
          Returns true if this FlattenedComponent is currently flattening its children
 void processDecodes(FacesContext context)
          Only decode the currently active facet.
<S> boolean
processFlattenedChildren(FacesContext context, ComponentProcessingContext cpContext, ComponentProcessor<S> childProcessor, S callbackContext)
          Processes the selected switcher facet
 void processUpdates(FacesContext context)
          Only process updates on the currently active facet.
 void processValidators(FacesContext context)
          Only process validations on the currently active 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.
protected  boolean visitChildren(VisitContext visitContext, VisitCallback callback)
          Hook for subclasses to override the manner in which the component's children are visited.
 
Methods inherited from class org.apache.myfaces.trinidad.component.UIXComponentBase
adaptMethodBinding, addAttributeChange, addAttributeChangeListener, addFacesListener, broadcast, broadcastToMethodBinding, broadcastToMethodExpression, createFacesBean, decode, decodeChildren, decodeChildrenImpl, encodeBegin, encodeEnd, findComponent, getAttributeChangeListener, getAttributeChangeListeners, getAttributes, getBooleanProperty, getChildCount, getChildren, getClientId, getContainerClientId, getFacesBean, getFacesContext, getFacesListeners, getFacet, getFacetCount, getFacetNames, getFacets, getFacetsAndChildren, getId, getIntProperty, getLifecycleRenderer, getParent, getProperty, getPropertyKey, getRenderer, getRendererType, getValueBinding, getValueExpression, invokeOnChildrenComponents, invokeOnComponent, invokeOnNamingContainerComponent, isRendered, isTransient, markInitialState, processRestoreState, processSaveState, queueEvent, removeAttributeChangeListener, removeFacesListener, restoreState, satisfiesPartialTrigger, saveState, setAttributeChangeListener, setAttributeChangeListener, setBooleanProperty, setId, setIntProperty, setParent, setProperty, setRendered, setRendererType, setTransient, setValueBinding, setValueExpression, toString, updateChildren, updateChildrenImpl, validateChildren, validateChildrenImpl
 
Methods inherited from class org.apache.myfaces.trinidad.component.UIXComponent
addPartialTarget, clearCachedClientIds, clearCachedClientIds, encodeFlattenedChild, encodeFlattenedChildren, isVisitable, partialEncodeVisit, processFlattenedChildren, processFlattenedChildren, processFlattenedChildren, processFlattenedChildren, setPartialTarget, setupChildrenVisitingContext, setupEncodingContext, setUpEncodingContext, setupVisitingContext, tearDownChildrenVisitingContext, tearDownEncodingContext, tearDownVisitingContext, visitTree, visitTree
 
Methods inherited from class javax.faces.component.UIComponent
encodeAll, getContainerClientId
 
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

processDecodes

public void processDecodes(FacesContext context)
Only decode the currently active facet.

Overrides:
processDecodes in class UIXComponentBase

processValidators

public void processValidators(FacesContext context)
Only process validations on the currently active facet.

Overrides:
processValidators in class UIXComponentBase

processUpdates

public void processUpdates(FacesContext context)
Only process updates on the currently active facet.

Overrides:
processUpdates in class UIXComponentBase

processFlattenedChildren

public <S> boolean processFlattenedChildren(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(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(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

visitChildren

protected boolean visitChildren(VisitContext visitContext,
                                VisitCallback callback)
Description copied from class: UIXComponent
Hook for subclasses to override the manner in which the component's children are visited. The default implementation visits all of the children and facets of the Component. setupChildrenVisitingContext will have been called before this method is invoked and tearDownChildrenVisitingContext will be called after. respectively. If the purpose of this visit was to encode the component and the component uses a CoreRenderer, the CoreRenderer's setupChildrenEncodingContext and tearDownChildrenEncodingContext will be called before and after this method is invoked, respectively.

Overrides:
visitChildren in class UIXComponent
Parameters:
visitContext - the VisitContext for this visit
callback - the VisitCallback instance
Returns:
true if the visit is complete.
See Also:
UIXComponent.setupChildrenVisitingContext(javax.faces.context.FacesContext), UIXComponent.tearDownChildrenVisitingContext(javax.faces.context.FacesContext), CoreRenderer.setupChildrenEncodingContext(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RenderingContext, javax.faces.component.UIComponent), CoreRenderer.tearDownChildrenEncodingContext(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RenderingContext, javax.faces.component.UIComponent)

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-2011 The Apache Software Foundation. All Rights Reserved.