com.sun.rave.web.ui.component.util.descriptors
Class LayoutComponent

java.lang.Object
  extended by com.sun.rave.web.ui.component.util.descriptors.LayoutElementBase
      extended by com.sun.rave.web.ui.component.util.descriptors.LayoutComponent
All Implemented Interfaces:
LayoutElement, java.io.Serializable

public class LayoutComponent
extends LayoutElementBase
implements LayoutElement

This class defines a LayoutComponent. A LayoutComponent describes a UIComponent to be instantiated. The method getType() provides a ComponentType descriptor that is capable of providing a ComponentFactory to perform the actual instantiation. This class also stores properties and facets (children) to be set on a newly instantiated instance.

See Also:
Serialized Form

Field Summary
static java.lang.String AFTER_CREATE
           This is the "type" for handlers to be invoked to handle "afterCreate" functionality for this element.
static java.lang.String BEFORE_CREATE
           This is the "type" for handlers to be invoked to handle "beforeCreate" functionality for this element.
static java.lang.String FACET_NAME
           This defines the property key for specifying the facet name in which the component should be stored under in its parent UIComponent.
 
Fields inherited from class com.sun.rave.web.ui.component.util.descriptors.LayoutElementBase
AFTER_ENCODE, BEFORE_ENCODE, ENCODE
 
Constructor Summary
LayoutComponent(LayoutElement parent, java.lang.String id, ComponentType type)
           Constructor.
 
Method Summary
 void addChildLayoutElement(LayoutElement element)
           This method overrides LayoutElementBase.addChildLayoutElement().
 void addOption(java.lang.String name, java.lang.Object value)
           This method adds an option to the LayoutComponent.
 void addOptions(java.util.Map map)
           This method adds all the options in the given Map to the LayoutComponent.
 java.lang.Object afterCreate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           This method is invoked after the Component described by this LayoutComponent is created.
 java.lang.Object beforeCreate(javax.faces.context.FacesContext context, javax.faces.component.UIComponent parent)
           This method is invoked before the Component described by this LayoutComponent is created.
 boolean containsOption(java.lang.String name)
           This method returns true/false based on whether the given option name has been set.
protected  boolean encodeThis(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           This method allows each LayoutElement to provide it's own encode functionality.
 javax.faces.component.UIComponent getChild(javax.faces.context.FacesContext context, javax.faces.component.UIComponent parent)
           This method will find or create a UIComponent as described by this LayoutComponent descriptor.
 java.lang.Object getEvaluatedOption(javax.faces.context.FacesContext ctx, java.lang.String name, javax.faces.component.UIComponent component)
           Accessor method for an option.
 java.lang.Object getOption(java.lang.String name)
           Accessor method for an option.
 java.util.Map getOptions()
           This method returns the options as a Map.
 ComponentType getType()
           Accessor for type.
 boolean isFacetChild()
           This method returns true if the child should be added to the parent component as a facet.
 boolean isOverwrite()
           Determines if this component should be created even if there is already an existing UIComponent.
 void setFacetChild(boolean facetChild)
           This method sets whether the child UIComponent should be set as a facet or a real child.
 void setOptions(java.util.Map options)
           This method sets the Map of options.
 void setOverwrite(boolean value)
           Determines if this component should be created even if there is already an existing UIComponent.
 
Methods inherited from class com.sun.rave.web.ui.component.util.descriptors.LayoutElementBase
createHandlerContext, dispatchHandlers, dispatchHandlers, encode, encodeChild, getChildLayoutElements, getHandlers, getHandlers, getHandlersByTypeMap, getId, getLayoutDefinition, getParent, getUnevaluatedId, resolveValue, setHandlers, setHandlersByTypeMap, setParent
 
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.descriptors.LayoutElement
dispatchHandlers, dispatchHandlers, encode, getChildLayoutElements, getHandlers, getId, getLayoutDefinition, getParent, getUnevaluatedId, setHandlers
 

Field Detail

AFTER_CREATE

public static final java.lang.String AFTER_CREATE

This is the "type" for handlers to be invoked to handle "afterCreate" functionality for this element.

See Also:
Constant Field Values

BEFORE_CREATE

public static final java.lang.String BEFORE_CREATE

This is the "type" for handlers to be invoked to handle "beforeCreate" functionality for this element.

See Also:
Constant Field Values

FACET_NAME

public static final java.lang.String FACET_NAME

This defines the property key for specifying the facet name in which the component should be stored under in its parent UIComponent.

See Also:
Constant Field Values
Constructor Detail

LayoutComponent

public LayoutComponent(LayoutElement parent,
                       java.lang.String id,
                       ComponentType type)

Constructor.

Method Detail

getType

public ComponentType getType()

Accessor for type.


setOverwrite

public void setOverwrite(boolean value)

Determines if this component should be created even if there is already an existing UIComponent. It will "overwrite" the existing component if this property is true.


isOverwrite

public boolean isOverwrite()

Determines if this component should be created even if there is already an existing UIComponent. It will "overwrite" the existing component if this property is true.


addChildLayoutElement

public void addChildLayoutElement(LayoutElement element)

This method overrides LayoutElementBase.addChildLayoutElement(). Child LayoutElements for LayoutComponent are limited to LayoutFacet objects. This method ensures that only LayoutFacet objects are added. If any other types are added, an IllegalArgumentException will be thrown.

Specified by:
addChildLayoutElement in interface LayoutElement
Overrides:
addChildLayoutElement in class LayoutElementBase
Parameters:
element - The LayoutElement to add.
Throws:
java.lang.IllegalArgumentException - Thrown if LayoutElement is not a LayoutFacet

addOption

public void addOption(java.lang.String name,
                      java.lang.Object value)

This method adds an option to the LayoutComponent. Options may be useful in constructing the LayoutComponent.

Parameters:
name - The name of the option
value - The value of the option (may be List or String)

addOptions

public void addOptions(java.util.Map map)

This method adds all the options in the given Map to the LayoutComponent. Options may be useful in constructing the LayoutComponent.

Parameters:
map - The map of options to add.

getOption

public java.lang.Object getOption(java.lang.String name)

Accessor method for an option. This method does not evaluate expressions.

Parameters:
name - The option name to retrieve.
Returns:
The option value (List or String), or null if not found.
See Also:
getEvaluatedOption(FacesContext, String, UIComponent)

getEvaluatedOption

public java.lang.Object getEvaluatedOption(javax.faces.context.FacesContext ctx,
                                           java.lang.String name,
                                           javax.faces.component.UIComponent component)

Accessor method for an option. This method evaluates our own expressions (not JSF expressions).

Parameters:
name - The option name to retrieve
ctx - The FacesContext
component - The UIComponent (may be null)
Returns:
The option value (List or String), or null if not found.
See Also:
getOption(String)

containsOption

public boolean containsOption(java.lang.String name)

This method returns true/false based on whether the given option name has been set.

Parameters:
name - The option name to look for.
Returns:
true/false depending on whether the options exists.

setOptions

public void setOptions(java.util.Map options)

This method sets the Map of options.

Parameters:
options - Map of options.

getOptions

public java.util.Map getOptions()

This method returns the options as a Map. This method does not evaluate expressions.

Returns:
Map of options.

encodeThis

protected boolean encodeThis(javax.faces.context.FacesContext context,
                             javax.faces.component.UIComponent component)
                      throws java.io.IOException

This method allows each LayoutElement to provide it's own encode functionality. If the LayoutComponent should render its children, this method should return true. Otherwise, this method should return false.

Specified by:
encodeThis in class LayoutElementBase
Parameters:
context - The FacesContext
component - The UIComponent
Returns:
true if children are to be rendered, false otherwise.
Throws:
java.io.IOException

getChild

public javax.faces.component.UIComponent getChild(javax.faces.context.FacesContext context,
                                                  javax.faces.component.UIComponent parent)
                                           throws java.io.IOException

This method will find or create a UIComponent as described by this LayoutComponent descriptor. If the component already exists as a child or facet, it will be returned. If it creates a new UIComponent, it will typically be added to the given parent UIComponent as a facet (this actually depends on the factory that instantiates the UIComponent).

Parameters:
context - The FacesContext
parent - The UIComponent to serve as the parent to search and to store the new UIComponent.
Returns:
The UIComponent requested (found or newly created)
Throws:
java.io.IOException

beforeCreate

public java.lang.Object beforeCreate(javax.faces.context.FacesContext context,
                                     javax.faces.component.UIComponent parent)

This method is invoked before the Component described by this LayoutComponent is created. This allows handlers registered for "beforeCreate" functionality to be invoked.

Parameters:
context - The FacesContext
Returns:
The result of invoking the handlers (null by default)

afterCreate

public java.lang.Object afterCreate(javax.faces.context.FacesContext context,
                                    javax.faces.component.UIComponent component)

This method is invoked after the Component described by this LayoutComponent is created. This allows handlers registered for "afterCreate" functionality to be invoked.

Parameters:
context - The FacesContext
Returns:
The result of invoking the handlers (null by default)

isFacetChild

public boolean isFacetChild()

This method returns true if the child should be added to the parent component as a facet. Otherwise, it returns false indicating that it should exist as a real child. The default is true.

Returns:
True if the child UIComponent should be added as a facet.

setFacetChild

public void setFacetChild(boolean facetChild)

This method sets whether the child UIComponent should be set as a facet or a real child.

Parameters:
facetChild - True if the child UIComponent should be added as a facet.