org.apache.myfaces.trinidad.render
Class CoreRenderer

java.lang.Object
  extended by javax.faces.render.Renderer
      extended by org.apache.myfaces.trinidad.render.CoreRenderer

public class CoreRenderer
extends javax.faces.render.Renderer

Basic implementation of the core rendering functionality across render kits.


Field Summary
static char CHAR_UNDEFINED
           
static int NO_CHILD_INDEX
           
 
Constructor Summary
protected CoreRenderer()
           
 
Method Summary
protected  void afterEncode(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component, FacesBean bean)
          Hook method that gets invoked after the component is encoded
protected  void beforeEncode(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component, FacesBean bean)
          Hook method that gets invoked before the component is encoded
 void decode(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
          
protected  void decode(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, FacesBean facesBean, String clientId)
          Hook for sub-classes to perform their own decode logic
protected  String decodeBehaviors(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, FacesBean bean)
          Decodes the behaviors of this component, if it is the component that is the source of the call to the server and the event matches behaviors that are attached to the component
protected  void delegateRenderer(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component, FacesBean bean, CoreRenderer renderer)
           
protected  void delegateRendererBegin(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component, FacesBean bean, CoreRenderer renderer)
           
protected  void delegateRendererEnd(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component, FacesBean bean, CoreRenderer renderer)
           
protected  void encodeAll(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component, FacesBean bean)
          Hook for rendering all of a component; only called if getRendersChildren() is true.
protected  void encodeAllChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
protected  void encodeBegin(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component, FacesBean bean)
          Hook for rendering the start of a component; only called if getRendersChildren() is false.
 void encodeBegin(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
protected  void encodeChild(javax.faces.context.FacesContext context, javax.faces.component.UIComponent child)
          Hook for encoding a child; this assumes that isRendered() has already been called.
 void encodeChildren(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
protected  void encodeComponentResources(javax.faces.context.FacesContext context, String target)
          Hook for rendering the component resources for the target.
protected  void encodeEnd(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component, FacesBean bean)
          Hook for rendering the end of a component; only called if getRendersChildren() is false.
 void encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
static Collection<javax.faces.component.behavior.ClientBehaviorContext.Parameter> getBehaviorParameters(javax.faces.component.UIComponent component)
          Get a collection of all the parameters that are children of the current component as client behavior parameters.
protected  String getClientId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Returns the client ID that should be used for rendering (if shouldRenderId(javax.faces.context.FacesContext, javax.faces.component.UIComponent) returns true).
protected  FacesBean getFacesBean(javax.faces.component.UIComponent component)
           
static javax.faces.component.UIComponent getFacet(javax.faces.component.UIComponent component, String name)
          Gets a facet, verifying that the facet should be rendered.
static int getNextRenderedChildIndex(List<javax.faces.component.UIComponent> components, int afterChildIndex)
           
static int getRenderedChildCount(javax.faces.component.UIComponent component)
          Returns the total number of children with rendered=="true".
 Iterator<javax.faces.component.UIComponent> getRenderedFacetsAndChildren(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
          Allows the rendered to specify what components should be involved with rendered children life-cycle operations and methods.
protected static Object getRenderingProperty(RenderingContext rc, Object key)
           
static boolean hasRenderedChildren(javax.faces.component.UIComponent component)
          Returns true if the component has children and at least one has rendered=="true".
static boolean isDesktop(RenderingContext rc)
           
static boolean isGecko(RenderingContext rc)
           
static boolean isGenericPDA(RenderingContext rc)
           
static boolean isIE(RenderingContext rc)
           
static boolean isInaccessibleMode(RenderingContext rc)
           
static boolean isIPhone(RenderingContext rc)
           
static boolean isKonqueror(RenderingContext rc)
           
static boolean isNokiaS60(RenderingContext rc)
          This method returns true if a user-agent's platform is NokiaS60
static boolean isOpera(RenderingContext rc)
           
static boolean isPDA(RenderingContext rc)
           
static boolean isScreenReaderMode(RenderingContext rc)
           
static boolean isWebKit(RenderingContext rc)
           
 javax.faces.component.visit.VisitResult partialEncodeVisit(javax.faces.component.visit.VisitContext visitContext, PartialPageContext partialContext, javax.faces.component.UIComponent component, javax.faces.component.visit.VisitCallback callback)
           Called when visiting the CoreRenderer's component during optimized partial page encoding so that the CoreRenderer can modify what is actually encoded.
protected  void renderEncodedActionURI(javax.faces.context.FacesContext context, String name, Object value)
           
protected  void renderEncodedResourceURI(javax.faces.context.FacesContext context, String name, Object value)
           
protected  void renderId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Renders the client ID as an "id".
static void renderStyleClass(javax.faces.context.FacesContext context, RenderingContext rc, String styleClass)
          Render a generic CSS styleClass (not one derived from an attribute).
static void renderStyleClasses(javax.faces.context.FacesContext context, RenderingContext rc, String[] styleClasses)
          Render an array of CSS styleClasses as space-separated values.
protected static Object setRenderingProperty(RenderingContext rc, Object key, Object value)
           
 void setupChildrenEncodingContext(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component)
           Called before rendering the current component's children in order to set up any special context.
 void setupEncodingContext(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component)
           Called before rendering the current comopnent's children in order to set up any special context.
 void setupEncodingContext(javax.faces.context.FacesContext context, RenderingContext rc, UIXComponent component)
          Deprecated. 
protected  boolean shouldRenderId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Returns true if the component should render an ID.
protected  boolean skipDecode(javax.faces.context.FacesContext context)
           
 void tearDownChildrenEncodingContext(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component)
           Called after rendering the current component's children in order to tear down any special context.
 void tearDownEncodingContext(javax.faces.context.FacesContext context, RenderingContext rc, javax.faces.component.UIComponent component)
           Called after rendering the current component in order to tear down any special context.
 void tearDownEncodingContext(javax.faces.context.FacesContext context, RenderingContext rc, UIXComponent component)
          Deprecated. 
static String toActionUri(javax.faces.context.FacesContext fc, Object o)
          Coerces an object into an action URI, calling the view-handler.
static char toChar(Object o)
          Returns the character value of an object, XhtmlConstants.CHAR_UNDEFINED if there is none.
static int toInt(Object o)
          Returns the integer value of an object; this does not support null (which must be substituted with a default before calling).
static long toLong(Object o)
          Returns the integer value of an object; this does not support null (which must be substituted with a default before calling).
static String toResourceUri(javax.faces.context.FacesContext fc, Object o)
          Coerces an object into a resource URI, calling the view-handler.
static String toString(Object o)
          Coerces an object into a String.
static String toUri(Object o)
          Deprecated. use toResourceUri
 boolean visitChildrenForEncoding(UIXComponent component, javax.faces.component.visit.VisitContext visitContext, javax.faces.component.visit.VisitCallback callback)
          Hook to allow the renderer to customize the visitation of the children components of a component during the visitation of a component during rendering.
 
Methods inherited from class javax.faces.render.Renderer
convertClientId, getConvertedValue, getRendersChildren
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CHAR_UNDEFINED

public static final char CHAR_UNDEFINED
See Also:
Constant Field Values

NO_CHILD_INDEX

public static final int NO_CHILD_INDEX
See Also:
Constant Field Values
Constructor Detail

CoreRenderer

protected CoreRenderer()
Method Detail

getRenderedFacetsAndChildren

public Iterator<javax.faces.component.UIComponent> getRenderedFacetsAndChildren(javax.faces.context.FacesContext facesContext,
                                                                                javax.faces.component.UIComponent component)
Allows the rendered to specify what components should be involved with rendered children life-cycle operations and methods.

Parameters:
facesContext - the faces context
component - the component from which to get the rendered facets and children
Returns:
A list of components to process as rendered components. Defaults to all facets and children of a component
See Also:
UIXComponentBase#getRenderedFacetsAndChildren(FacesContext)

partialEncodeVisit

public javax.faces.component.visit.VisitResult partialEncodeVisit(javax.faces.component.visit.VisitContext visitContext,
                                                                  PartialPageContext partialContext,
                                                                  javax.faces.component.UIComponent component,
                                                                  javax.faces.component.visit.VisitCallback callback)

Called when visiting the CoreRenderer's component during optimized partial page encoding so that the CoreRenderer can modify what is actually encoded. For example tab controls often render the tabs for the ShowDetailItems in the tab bar before delegating to the disclosed ShowDetailItem to render the tab content. As a result, the tab control needs to encode its tab bar if any of its ShowDetailItems are partial targets so that the tab labels, for example, are up-to-date.

The default implementation calls the VisitCallback and returns its result if this UIXComponent is a partial target of the current encoding.

Parameters:
visitContext - VisitContext to pass to the VisitCallback
partialContext - PartialPageContext for the current partial encoding
component - The component for the CoreRenderer to visit
callback - VisitCallback to call if this component is a partial target
Returns:
The VisitResult controlling continued iteration of the visit.

setupEncodingContext

public void setupEncodingContext(javax.faces.context.FacesContext context,
                                 RenderingContext rc,
                                 javax.faces.component.UIComponent component)

Called before rendering the current comopnent's children in order to set up any special context.

If setupEncodingContext succeeds then tearDownEncodingContext will be called for the same component.

The default implementation does nothing

Parameters:
context - FacesContext for this request
rc - RenderingContext for this encoding pass
See Also:
tearDownEncodingContext(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RenderingContext, javax.faces.component.UIComponent)

setupEncodingContext

@Deprecated
public void setupEncodingContext(javax.faces.context.FacesContext context,
                                            RenderingContext rc,
                                            UIXComponent component)
Deprecated. 


setupChildrenEncodingContext

public void setupChildrenEncodingContext(javax.faces.context.FacesContext context,
                                         RenderingContext rc,
                                         javax.faces.component.UIComponent component)

Called before rendering the current component's children in order to set up any special context.

If setupChildrenEncodingContext succeeds then tearDownChildrenEncodingContext will be called for the same component.

The default implementation does nothing

Parameters:
context - FacesContext for this request
rc - RenderingContext for this encoding pass
component - Component to encode using this Renderer
See Also:
tearDownChildrenEncodingContext(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RenderingContext, javax.faces.component.UIComponent)

tearDownEncodingContext

public void tearDownEncodingContext(javax.faces.context.FacesContext context,
                                    RenderingContext rc,
                                    javax.faces.component.UIComponent component)

Called after rendering the current component in order to tear down any special context.

tearDownEncodingContext will be called on the component if setupEncodingContext succeeded.

The default implementation does nothing

Parameters:
context - FacesContext for this request
rc - RenderingContext for this encoding pass
component - Component to encode using this Renderer
See Also:
setupEncodingContext(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RenderingContext, javax.faces.component.UIComponent)

visitChildrenForEncoding

public boolean visitChildrenForEncoding(UIXComponent component,
                                        javax.faces.component.visit.VisitContext visitContext,
                                        javax.faces.component.visit.VisitCallback callback)
Hook to allow the renderer to customize the visitation of the children components of a component during the visitation of a component during rendering.

Parameters:
component - the component which owns the children to visit
visitContext - the visitation context
callback - the visit callback
Returns:
true if the visit is complete.
See Also:
UIXComponent.visitChildren(VisitContext, VisitCallback)

tearDownEncodingContext

@Deprecated
public void tearDownEncodingContext(javax.faces.context.FacesContext context,
                                               RenderingContext rc,
                                               UIXComponent component)
Deprecated. 


tearDownChildrenEncodingContext

public void tearDownChildrenEncodingContext(javax.faces.context.FacesContext context,
                                            RenderingContext rc,
                                            javax.faces.component.UIComponent component)

Called after rendering the current component's children in order to tear down any special context.

tearDownChildrenEncodingContext will be called on the component if setupChildrenEncodingContext succeeded.

The default implementation does nothing

Parameters:
context - FacesContext for this request
rc - RenderingContext for this encoding pass
component - Component to encode using this Renderer
See Also:
setupChildrenEncodingContext(javax.faces.context.FacesContext, org.apache.myfaces.trinidad.context.RenderingContext, javax.faces.component.UIComponent)

decode

public final void decode(javax.faces.context.FacesContext facesContext,
                         javax.faces.component.UIComponent component)

Sub-classes should override the decode(FacesContext, UIComponent, FacesBean, String) method to perform their own decoding logic

Overrides:
decode in class javax.faces.render.Renderer
See Also:
decode(FacesContext, UIComponent, FacesBean, String)

decode

protected void decode(javax.faces.context.FacesContext facesContext,
                      javax.faces.component.UIComponent component,
                      FacesBean facesBean,
                      String clientId)
Hook for sub-classes to perform their own decode logic

Parameters:
facesContext - the faces context
component - the component to decode
facesBean - the faces bean for the component
clientId - the client ID if it has been retrieved already during decoding, otherwise it will be null. Passed in for performance reasons, so that if it has already been retrieved it will not need to be retrieved again

toString

public static String toString(Object o)
Coerces an object into a String.


toResourceUri

public static String toResourceUri(javax.faces.context.FacesContext fc,
                                   Object o)
Coerces an object into a resource URI, calling the view-handler.


toActionUri

public static String toActionUri(javax.faces.context.FacesContext fc,
                                 Object o)
Coerces an object into an action URI, calling the view-handler.


toUri

@Deprecated
public static String toUri(Object o)
Deprecated. use toResourceUri

Coerces an object into a resource URI, calling the view-handler.


toInt

public static int toInt(Object o)
Returns the integer value of an object; this does not support null (which must be substituted with a default before calling).


toLong

public static long toLong(Object o)
Returns the integer value of an object; this does not support null (which must be substituted with a default before calling).


toChar

public static char toChar(Object o)
Returns the character value of an object, XhtmlConstants.CHAR_UNDEFINED if there is none.


encodeBegin

public final void encodeBegin(javax.faces.context.FacesContext context,
                              javax.faces.component.UIComponent component)
                       throws IOException
Overrides:
encodeBegin in class javax.faces.render.Renderer
Throws:
IOException

encodeChildren

public final void encodeChildren(javax.faces.context.FacesContext context,
                                 javax.faces.component.UIComponent component)
Overrides:
encodeChildren in class javax.faces.render.Renderer

encodeEnd

public final void encodeEnd(javax.faces.context.FacesContext context,
                            javax.faces.component.UIComponent component)
                     throws IOException
Overrides:
encodeEnd in class javax.faces.render.Renderer
Throws:
IOException

encodeBegin

protected void encodeBegin(javax.faces.context.FacesContext context,
                           RenderingContext rc,
                           javax.faces.component.UIComponent component,
                           FacesBean bean)
                    throws IOException
Hook for rendering the start of a component; only called if getRendersChildren() is false.

Throws:
IOException

encodeComponentResources

protected final void encodeComponentResources(javax.faces.context.FacesContext context,
                                              String target)
                                       throws IOException
Hook for rendering the component resources for the target.

Parameters:
context - Current FacesContext object for this request.
target - The target for the resources (e.g. head/body/form)
Throws:
IOException

encodeEnd

protected void encodeEnd(javax.faces.context.FacesContext context,
                         RenderingContext rc,
                         javax.faces.component.UIComponent component,
                         FacesBean bean)
                  throws IOException
Hook for rendering the end of a component; only called if getRendersChildren() is false.

Throws:
IOException

encodeAll

protected void encodeAll(javax.faces.context.FacesContext context,
                         RenderingContext rc,
                         javax.faces.component.UIComponent component,
                         FacesBean bean)
                  throws IOException
Hook for rendering all of a component; only called if getRendersChildren() is true.

Throws:
IOException

encodeChild

protected void encodeChild(javax.faces.context.FacesContext context,
                           javax.faces.component.UIComponent child)
                    throws IOException
Hook for encoding a child; this assumes that isRendered() has already been called. (RenderUtils.encodeRecursive() can be used if you don't need that check.) =-=AEW Ugh.

Throws:
IOException

encodeAllChildren

protected void encodeAllChildren(javax.faces.context.FacesContext context,
                                 javax.faces.component.UIComponent component)
                          throws IOException
Throws:
IOException

delegateRenderer

protected void delegateRenderer(javax.faces.context.FacesContext context,
                                RenderingContext rc,
                                javax.faces.component.UIComponent component,
                                FacesBean bean,
                                CoreRenderer renderer)
                         throws IOException
Throws:
IOException

delegateRendererBegin

protected void delegateRendererBegin(javax.faces.context.FacesContext context,
                                     RenderingContext rc,
                                     javax.faces.component.UIComponent component,
                                     FacesBean bean,
                                     CoreRenderer renderer)
                              throws IOException
Throws:
IOException

delegateRendererEnd

protected void delegateRendererEnd(javax.faces.context.FacesContext context,
                                   RenderingContext rc,
                                   javax.faces.component.UIComponent component,
                                   FacesBean bean,
                                   CoreRenderer renderer)
                            throws IOException
Throws:
IOException

renderId

protected void renderId(javax.faces.context.FacesContext context,
                        javax.faces.component.UIComponent component)
                 throws IOException
Renders the client ID as an "id".

Throws:
IOException

getClientId

protected String getClientId(javax.faces.context.FacesContext context,
                             javax.faces.component.UIComponent component)
Returns the client ID that should be used for rendering (if shouldRenderId(javax.faces.context.FacesContext, javax.faces.component.UIComponent) returns true).


shouldRenderId

protected boolean shouldRenderId(javax.faces.context.FacesContext context,
                                 javax.faces.component.UIComponent component)
Returns true if the component should render an ID. Components that deliver events should always return "true".


skipDecode

protected boolean skipDecode(javax.faces.context.FacesContext context)

getFacesBean

protected FacesBean getFacesBean(javax.faces.component.UIComponent component)

getRenderingProperty

protected static final Object getRenderingProperty(RenderingContext rc,
                                                   Object key)

setRenderingProperty

protected static final Object setRenderingProperty(RenderingContext rc,
                                                   Object key,
                                                   Object value)

getFacet

public static javax.faces.component.UIComponent getFacet(javax.faces.component.UIComponent component,
                                                         String name)
Gets a facet, verifying that the facet should be rendered.


hasRenderedChildren

public static boolean hasRenderedChildren(javax.faces.component.UIComponent component)
Returns true if the component has children and at least one has rendered=="true".


getRenderedChildCount

public static int getRenderedChildCount(javax.faces.component.UIComponent component)
Returns the total number of children with rendered=="true".


getNextRenderedChildIndex

public static int getNextRenderedChildIndex(List<javax.faces.component.UIComponent> components,
                                            int afterChildIndex)
Parameters:
afterChildIndex - The children coming after this index, will be considered.
Returns:
the index of the next child that must be rendered, or NO_CHILD_INDEX if there is none.

isDesktop

public static boolean isDesktop(RenderingContext rc)

isPDA

public static boolean isPDA(RenderingContext rc)

isIE

public static boolean isIE(RenderingContext rc)

isKonqueror

public static boolean isKonqueror(RenderingContext rc)

isGecko

public static boolean isGecko(RenderingContext rc)

isWebKit

public static boolean isWebKit(RenderingContext rc)

isOpera

public static boolean isOpera(RenderingContext rc)

isIPhone

public static boolean isIPhone(RenderingContext rc)

isGenericPDA

public static boolean isGenericPDA(RenderingContext rc)

isNokiaS60

public static boolean isNokiaS60(RenderingContext rc)
This method returns true if a user-agent's platform is NokiaS60

Parameters:
arc - - RenderingContext of a request
Returns:
boolean

isInaccessibleMode

public static boolean isInaccessibleMode(RenderingContext rc)

isScreenReaderMode

public static boolean isScreenReaderMode(RenderingContext rc)

beforeEncode

protected void beforeEncode(javax.faces.context.FacesContext context,
                            RenderingContext rc,
                            javax.faces.component.UIComponent component,
                            FacesBean bean)
Hook method that gets invoked before the component is encoded

See Also:
#encodeBegin(FacesContext, RederingContext, UIComponent, FacesBean), #encodeAll(FacesContext, RederingContext, UIComponent, FacesBean)

afterEncode

protected void afterEncode(javax.faces.context.FacesContext context,
                           RenderingContext rc,
                           javax.faces.component.UIComponent component,
                           FacesBean bean)
Hook method that gets invoked after the component is encoded

See Also:
#encodeEnd(FacesContext, RederingContext, UIComponent, FacesBean), #encodeAll(FacesContext, RederingContext, UIComponent, FacesBean)

decodeBehaviors

protected final String decodeBehaviors(javax.faces.context.FacesContext facesContext,
                                       javax.faces.component.UIComponent component,
                                       FacesBean bean)
Decodes the behaviors of this component, if it is the component that is the source of the call to the server and the event matches behaviors that are attached to the component

Parameters:
facesContext - the faces context
component - the component
bean - the faces bean
Returns:
the client ID if it was retrieved, null otherwise

getBehaviorParameters

public static Collection<javax.faces.component.behavior.ClientBehaviorContext.Parameter> getBehaviorParameters(javax.faces.component.UIComponent component)
Get a collection of all the parameters that are children of the current component as client behavior parameters.

Parameters:
component - The component
Returns:
Collection of parameters (will be non-null)

renderEncodedActionURI

protected void renderEncodedActionURI(javax.faces.context.FacesContext context,
                                      String name,
                                      Object value)
                               throws IOException
Throws:
IOException

renderEncodedResourceURI

protected void renderEncodedResourceURI(javax.faces.context.FacesContext context,
                                        String name,
                                        Object value)
                                 throws IOException
Throws:
IOException

renderStyleClass

public static void renderStyleClass(javax.faces.context.FacesContext context,
                                    RenderingContext rc,
                                    String styleClass)
                             throws IOException
Render a generic CSS styleClass (not one derived from an attribute). The styleclass will be passed through the RenderingContext getStyleClass() API.

Parameters:
context - the FacesContext
styleClass - the style class
Throws:
IOException

renderStyleClasses

public static void renderStyleClasses(javax.faces.context.FacesContext context,
                                      RenderingContext rc,
                                      String[] styleClasses)
                               throws IOException
Render an array of CSS styleClasses as space-separated values.

Parameters:
context - the FacesContext
styleClasses - the style classes
Throws:
IOException


Copyright © 2001-2012 The Apache Software Foundation. All Rights Reserved.