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.

Version:
$Revision: 1.2 $ $Date: 2003/06/04 17:38:13 $
Author:
Craig R. McClanahan

Constructor Summary
AbstractRenderer()
           
 
Method Summary
protected  void addConverterMessage(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String text)
          Add an error message denoting a conversion failure.
 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.
protected  javax.faces.application.Application getApplication()
          Return the Application instance for this webapp.
protected  java.lang.Object getAsObject(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String value)
          Convert the String representation of this component's value to the corresponding Object representation.
protected  java.lang.String getAsString(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object value)
          Convert the Object representation of this component's value to the corresponding String representation.
 java.lang.String getClientId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Return the client-side id for the argument component.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractRenderer

public AbstractRenderer()
Method Detail

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

addConverterMessage

protected void addConverterMessage(javax.faces.context.FacesContext context,
                                   javax.faces.component.UIComponent component,
                                   java.lang.String text)

Add an error message denoting a conversion failure.

Parameters:
context - The FacesContext for this request
component - The UIComponent that experienced the conversion failure
text - The text of the error message

getApplication

protected javax.faces.application.Application getApplication()

Return the Application instance for this webapp.


getAsObject

protected java.lang.Object getAsObject(javax.faces.context.FacesContext context,
                                       javax.faces.component.UIComponent component,
                                       java.lang.String value)
                                throws javax.faces.convert.ConverterException

Convert the String representation of this component's value to the corresponding Object representation. The default implementation utilizes the getAsObject() method of any associated Converter.

Parameters:
context - The FacesContext for this request
component - The UIComponent whose value is being converted
value - The String representation to be converted
Throws:
javax.faces.convert.ConverterException - if conversion fails

getAsString

protected java.lang.String getAsString(javax.faces.context.FacesContext context,
                                       javax.faces.component.UIComponent component,
                                       java.lang.Object value)
                                throws javax.faces.convert.ConverterException

Convert the Object representation of this component's value to the corresponding String representation. The default implementation utilizes the getAsString() method of any associated Converter.

Parameters:
context - The FacesContext for this request
component - The UIComponent whose value is being converted
value - The Object representation to be converted
Throws:
javax.faces.convert.ConverterException - if conversion fails


Copyright © 2003 - Apache Software Foundation