com.sun.rave.web.ui.component.util.factories
Class ComponentFactoryBase

java.lang.Object
  extended by com.sun.rave.web.ui.component.util.factories.ComponentFactoryBase
All Implemented Interfaces:
ComponentFactory
Direct Known Subclasses:
AnchorFactory, ButtonFactory, FieldFactory, HelpInlineFactory, HyperlinkFactory, IconFactory, IconHyperlinkFactory, ImageComponentFactory, ImageHyperlinkFactory, LabelFactory, LegendFactory, LocalizedStringFactory, StaticTextFactory

public abstract class ComponentFactoryBase
extends java.lang.Object
implements ComponentFactory

This abstract class provides common functionality for UIComponent factories.


Constructor Summary
ComponentFactoryBase()
           
 
Method Summary
protected  void addChild(javax.faces.context.FacesContext context, LayoutComponent descriptor, javax.faces.component.UIComponent parent, javax.faces.component.UIComponent child)
           This method associates the given child with the given parent.
protected  java.lang.Object getEvaluatedOption(javax.faces.context.FacesContext context, LayoutComponent desc, javax.faces.component.UIComponent parent, java.lang.String key, boolean required)
          Deprecated. I *think* only the LayoutComponent version of this should be used...
protected  void setOptions(javax.faces.context.FacesContext context, LayoutComponent desc, javax.faces.component.UIComponent comp)
           This method iterates through the Map of options.
protected  void storeInstanceHandlers(LayoutComponent desc, javax.faces.component.UIComponent comp)
           This method is responsible for interating over the "instance" handlers and applying them to the UIComponent.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface com.sun.rave.web.ui.component.util.factories.ComponentFactory
create
 

Constructor Detail

ComponentFactoryBase

public ComponentFactoryBase()
Method Detail

setOptions

protected void setOptions(javax.faces.context.FacesContext context,
                          LayoutComponent desc,
                          javax.faces.component.UIComponent comp)

This method iterates through the Map of options. It looks at each one, if it contians an EL expression, it sets a value binding. Otherwise, it calls setAttribute() on the component (which in turn will invoke the bean setter if there is one).

This method also interates through the child LayoutElements of the given LayoutComponent descriptor and adds Facets or children as appropriate.

Parameters:
context - The FacesContext
desc - The LayoutComponent descriptor associated with the requested UIComponent.
comp - The UIComponent

storeInstanceHandlers

protected void storeInstanceHandlers(LayoutComponent desc,
                                     javax.faces.component.UIComponent comp)

This method is responsible for interating over the "instance" handlers and applying them to the UIComponent. An "instance" handler is one that is defined outside a renderer, or a nested component within a renderer. In other words, a handler that would not get fired by the TemplateRenderer. By passing this in via the UIComponent, code that is aware of events (see LayoutElementBase) may find these events and fire them. These may vary per "instance" of a particular component (i.e. TreeNode) unlike the handlers defined in a TemplateRender's XML (which are shared and therefor should not change dynamically).

Parameters:
desc - The descriptor potentially containing handlers to copy.
comp - The UIComponent instance to store the handlers.

addChild

protected void addChild(javax.faces.context.FacesContext context,
                        LayoutComponent descriptor,
                        javax.faces.component.UIComponent parent,
                        javax.faces.component.UIComponent child)

This method associates the given child with the given parent. By using this method we centralize the code so that if we decide later to add it as a real child it can be done in one place.

Parameters:
context - The FacesContext
descriptor - The LayoutComponent descriptor associated with the requested UIComponent.
parent - The parent UIComponent
child - The child UIComponent

getEvaluatedOption

protected java.lang.Object getEvaluatedOption(javax.faces.context.FacesContext context,
                                              LayoutComponent desc,
                                              javax.faces.component.UIComponent parent,
                                              java.lang.String key,
                                              boolean required)
Deprecated. I *think* only the LayoutComponent version of this should be used...

This method is to be used by subclasses to retrieve a pre-evalated option by name. Since this is in the context of a factory, these options usually needed during the creation of the UIComponent. Therefor the parent UIComponent is typically passed in because of the lack of existence of the child UIComponent.

This method does not currently resolve #{} expressions.

Parameters:
context - The FacesContext
desc - The LayoutComponent descriptor holding the options
parent - Usually the parent UIComponent, only used when resolving $...{...} expressions
key - The option name to pull from desc
required - A flag indicating if a value for the property must exist. If true and the property value is null, an IllegalArgumentException will be thrown.
Returns:
The evaluated option, null if not found.
Throws:
java.lang.IllegalArgumentException - Thrown if property is required but has a null value (or not found).