org.apache.struts.faces.renderer
Class AbstractRenderer

java.lang.Object
  |
  +--javax.faces.render.Renderer
        |
        +--org.apache.struts.faces.renderer.AbstractRenderer
Direct Known Subclasses:
BaseRenderer, ErrorsRenderer, FormRenderer, HtmlRenderer, StylesheetRenderer, WriteRenderer

public abstract class AbstractRenderer
extends javax.faces.render.Renderer

Abstract base class for concrete implementations of javax.faces.render.Renderer for the Struts-Faces Integration Library.

IMPLEMENTATION NOTE - The default implementation assumes that a particular UIComponent class is supported if we have declared support for that class's component type.

Version:
$Revision: 1.1 $ $Date: 2003/03/07 03:22:44 $
Author:
Craig R. McClanahan

Field Summary
private  java.util.HashMap components
          The supported component descriptions for the component types supported by this Renderer, keyed by component type.
private  java.lang.String rendererType
          The renderer type implemented by this Renderer.
 
Constructor Summary
AbstractRenderer()
           
 
Method Summary
 void addSupportedComponent(SupportedComponent component)
          Add a new supported component for this Renderer.
 void decode(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Decode the current state of the specified UIComponent from the request contained in the specified FacesContext, and attempt to convert this state information into an object of the type equired for this component.
 void encodeBegin(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Render the beginning specified UIComponent to the output stream or writer associated with the response we are creating.
 void encodeChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Render the child components of this UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered.
 void encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Render the ending of the current state of the specified UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered.
 javax.faces.component.AttributeDescriptor getAttributeDescriptor(java.lang.String componentType, java.lang.String name)
          Return an AttributeDescriptor for the specified attribute name, as supported for the specified component type.
 javax.faces.component.AttributeDescriptor getAttributeDescriptor(javax.faces.component.UIComponent component, java.lang.String name)
          Return an AttributeDescriptor for the specified attribute name, as supported for the specified UIComponent class.
 java.util.Iterator getAttributeNames(java.lang.String componentType)
          Return an Iterator over the names of the supported attributes for the specified component type.
 java.util.Iterator getAttributeNames(javax.faces.component.UIComponent component)
          Return an Iterator over the names of the supported attributes for the specified UIComponent class.
 java.lang.String getClientId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Return the client-side id for the argument component.
 java.lang.String getRendererType()
          Return the renderer type for this Renderer.
 void setRendererType(java.lang.String rendererType)
          Set the renderer type for this Renderer.
 boolean supportsComponentType(java.lang.String componentType)
          Return true if this Renderer supports the specified component type.
 boolean supportsComponentType(javax.faces.component.UIComponent component)
          Return true if this Renderer supports the specified component class.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

components

private java.util.HashMap components

The supported component descriptions for the component types supported by this Renderer, keyed by component type.


rendererType

private java.lang.String rendererType

The renderer type implemented by this Renderer.

Constructor Detail

AbstractRenderer

public AbstractRenderer()
Method Detail

getRendererType

public java.lang.String getRendererType()

Return the renderer type for this Renderer.


setRendererType

public void setRendererType(java.lang.String rendererType)

Set the renderer type for this Renderer.

Parameters:
rendererType - The new renderer type

getClientId

public java.lang.String getClientId(javax.faces.context.FacesContext context,
                                    javax.faces.component.UIComponent component)

Return the client-side id for the argument component.

The purpose of this method is to give Renderers a chance to define, in a rendering specific way, the client side id for this component. The client side id should be derived from the component id, if present.

Look up this component's "clientId" attribute. If non-null, return it. Get the component id for the argument UIComponent. If null, generate one using the closest naming container that is an ancestor of this UIComponent, then set the generated id as the componentId of this UIComponent. Prepend to the component id the component ids of each naming container up to, but not including, the root, separated by the UIComponent.SEPARATOR_CHAR. In all cases, save the result as the value of the "clientId" attribute.

This method must not return null.

Specified by:
getClientId in class javax.faces.render.Renderer

decode

public void decode(javax.faces.context.FacesContext context,
                   javax.faces.component.UIComponent component)
            throws java.io.IOException

Decode the current state of the specified UIComponent from the request contained in the specified FacesContext, and attempt to convert this state information into an object of the type equired for this component.

Specified by:
decode in class javax.faces.render.Renderer
Parameters:
context - FacesContext for the request we are processing
component - UIComponent to be decoded
Returns:
true if conversion was successful (or no conversion processing was required), or false if conversion was not successful
Throws:
java.io.IOException - if an input/output error occurs while decoding
java.lang.NullPointerException - if context or component is null

encodeBegin

public void encodeBegin(javax.faces.context.FacesContext context,
                        javax.faces.component.UIComponent component)
                 throws java.io.IOException

Render the beginning specified UIComponent to the output stream or writer associated with the response we are creating. If the conversion attempted in a previous call to decode for this component failed, the state information saved during execution of decode() should be utilized to reproduce the incorrect input. If the conversion was successful, or if there was no previous call to decode(), the value to be displayed should be acquired by calling component.currentValue(), and rendering the value as appropriate.

Specified by:
encodeBegin in class javax.faces.render.Renderer
Parameters:
context - FacesContext for the request we are processing
component - UIComponent to be rendered
Throws:
java.io.IOException - if an input/output error occurs while rendering
java.lang.NullPointerException - if context or component is null

encodeChildren

public void encodeChildren(javax.faces.context.FacesContext context,
                           javax.faces.component.UIComponent component)
                    throws java.io.IOException

Render the child components of this UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered. This method will only be called if the rendersChildren property of this component is true.

Specified by:
encodeChildren in class javax.faces.render.Renderer
Parameters:
context - FacesContext for the response we are creating
component - UIComponent whose children are to be rendered
Throws:
java.io.IOException - if an input/output error occurs while rendering
java.lang.NullPointerException - if context is null

encodeEnd

public void encodeEnd(javax.faces.context.FacesContext context,
                      javax.faces.component.UIComponent component)
               throws java.io.IOException

Render the ending of the current state of the specified UIComponent, following the rules described for encodeBegin() to acquire the appropriate value to be rendered.

Specified by:
encodeEnd in class javax.faces.render.Renderer
Parameters:
context - FacesContext for the response we are creating
component - UIComponent whose children are to be rendered
Throws:
java.io.IOException - if an input/output error occurs while rendering
java.lang.NullPointerException - if context is null

getAttributeDescriptor

public javax.faces.component.AttributeDescriptor getAttributeDescriptor(java.lang.String componentType,
                                                                        java.lang.String name)

Return an AttributeDescriptor for the specified attribute name, as supported for the specified component type.

Specified by:
getAttributeDescriptor in class javax.faces.render.Renderer
Parameters:
componentType - Component type that is supported
name - Attribute naem for which to return a descriptor
Throws:
java.lang.IllegalArgumentException - if the specified component type is not supported
java.lang.IllegalArgumentException - if the specified attribute name is not supported for the specified component type
java.lang.NullPointerException - if componentType or name is null

getAttributeDescriptor

public javax.faces.component.AttributeDescriptor getAttributeDescriptor(javax.faces.component.UIComponent component,
                                                                        java.lang.String name)

Return an AttributeDescriptor for the specified attribute name, as supported for the specified UIComponent class.

Specified by:
getAttributeDescriptor in class javax.faces.render.Renderer
Parameters:
component - UIComponent whose implementation class is supported
name - Attribute naem for which to return a descriptor
Throws:
java.lang.IllegalArgumentException - if the specified component class is not supported
java.lang.IllegalArgumentException - if the specified attribute name is not supported for the specified component class
java.lang.NullPointerException - if component or name is null

getAttributeNames

public java.util.Iterator getAttributeNames(java.lang.String componentType)

Return an Iterator over the names of the supported attributes for the specified component type. If no attributes are supported, an empty Iterator is returned.

Specified by:
getAttributeNames in class javax.faces.render.Renderer
Parameters:
componentType - Component type that is supported
Throws:
java.lang.IllegalArgumentException - if the specified component type is not supported
java.lang.NullPointerException - if componentType is null

getAttributeNames

public java.util.Iterator getAttributeNames(javax.faces.component.UIComponent component)

Return an Iterator over the names of the supported attributes for the specified UIComponent class. If no attributes are supported, an empty Iterator is returned.

Specified by:
getAttributeNames in class javax.faces.render.Renderer
Parameters:
component - UIComponent whose implementation class is supported
Throws:
java.lang.IllegalArgumentException - if the specified component class is not supported
java.lang.NullPointerException - if component is null

supportsComponentType

public boolean supportsComponentType(java.lang.String componentType)

Return true if this Renderer supports the specified component type.

Specified by:
supportsComponentType in class javax.faces.render.Renderer
Parameters:
componentType - Component type to be checked

supportsComponentType

public boolean supportsComponentType(javax.faces.component.UIComponent component)

Return true if this Renderer supports the specified component class.

Specified by:
supportsComponentType in class javax.faces.render.Renderer
Parameters:
component - Component whose class is to be checked

addSupportedComponent

public void addSupportedComponent(SupportedComponent component)

Add a new supported component for this Renderer.

Parameters:
component - The supported component instance to be added


Copyright ? 2003 - Apache Software Foundation