com.sun.faces.renderkit.html_basic
Class HtmlBasicRenderer

java.lang.Object
  extended by javax.faces.render.Renderer
      extended by com.sun.faces.renderkit.html_basic.HtmlBasicRenderer
Direct Known Subclasses:
BaseTableRenderer, ButtonRenderer, FormRenderer, GroupRenderer, HtmlBasicInputRenderer, ImageRenderer, LinkRenderer, MessageRenderer, MessagesRenderer, OutcomeTargetRenderer, OutputMessageRenderer

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

HtmlBasicRenderer is a base class for implementing renderers for HtmlBasicRenderKit.


Nested Class Summary
static class HtmlBasicRenderer.OptionComponentInfo
          Structure to hold common info used by Select* components to reduce the number of times component attributes are evaluated when rendering options.
static class HtmlBasicRenderer.Param
          Simple class to encapsulate the name and value of a UIParameter.
 
Field Summary
protected static HtmlBasicRenderer.Param[] EMPTY_PARAMS
           
protected static java.util.logging.Logger logger
           
 
Constructor Summary
HtmlBasicRenderer()
           
 
Method Summary
protected  java.lang.String augmentIdReference(java.lang.String forValue, javax.faces.component.UIComponent fromComponent)
          Conditionally augment an id-reference value.
 java.lang.String convertClientId(javax.faces.context.FacesContext context, java.lang.String clientId)
           
 void decode(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
protected  java.lang.String decodeBehaviors(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
 void encodeEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
protected  void encodeRecursive(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Render nested child components by invoking the encode methods on those components, but only when the rendered property is true.
protected  java.util.Collection<javax.faces.component.behavior.ClientBehaviorContext.Parameter> getBehaviorParameters(javax.faces.component.UIComponent command)
          Collections parameters for use with Behavior script rendering.
protected  java.util.Iterator<javax.faces.component.UIComponent> getChildren(javax.faces.component.UIComponent component)
           
protected  java.lang.String getCurrentValue(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
protected  void getEndTextToRender(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String currentValue)
          Renderers override this method to write appropriate HTML content into the buffer.
protected  javax.faces.component.UIComponent getFacet(javax.faces.component.UIComponent component, java.lang.String name)
           
protected  javax.faces.component.UIComponent getForComponent(javax.faces.context.FacesContext context, java.lang.String forComponent, javax.faces.component.UIComponent component)
          Locates the component identified by forComponent
protected  java.lang.String getFormattedValue(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object currentValue)
           
protected  java.lang.String getFormattedValue(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object currentValue, javax.faces.convert.Converter converter)
          Overloads getFormattedValue to take a advantage of a previously obtained converter.
protected  java.util.Iterator getMessageIter(javax.faces.context.FacesContext context, java.lang.String forComponent, javax.faces.component.UIComponent component)
           
protected  HtmlBasicRenderer.Param[] getParamList(javax.faces.component.UIComponent command)
           
protected static java.util.Map<java.lang.String,java.util.List<javax.faces.component.behavior.ClientBehavior>> getPassThruBehaviors(javax.faces.component.UIComponent component, java.lang.String domEventName, java.lang.String componentEventName)
          When rendering pass thru attributes, we need to take any attached Behaviors into account.
 boolean getRendersChildren()
           
protected  java.lang.Object getValue(javax.faces.component.UIComponent component)
           
protected  boolean isBehaviorSource(javax.faces.context.FacesContext ctx, java.lang.String behaviorSourceId, java.lang.String componentClientId)
           
protected  void rendererParamsNotNull(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
protected  void setSubmittedValue(javax.faces.component.UIComponent component, java.lang.Object value)
          Renderers override this method to store the previous value of the associated component.
protected  boolean shouldDecode(javax.faces.component.UIComponent component)
           
protected  boolean shouldEncode(javax.faces.component.UIComponent component)
           
protected  boolean shouldEncodeChildren(javax.faces.component.UIComponent component)
           
protected  boolean shouldWriteIdAttribute(javax.faces.component.UIComponent component)
           
protected  java.lang.String writeIdAttributeIfNecessary(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer, javax.faces.component.UIComponent component)
           
 
Methods inherited from class javax.faces.render.Renderer
encodeBegin, encodeChildren, getConvertedValue
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

protected static final java.util.logging.Logger logger

EMPTY_PARAMS

protected static final HtmlBasicRenderer.Param[] EMPTY_PARAMS
Constructor Detail

HtmlBasicRenderer

public HtmlBasicRenderer()
Method Detail

convertClientId

public java.lang.String convertClientId(javax.faces.context.FacesContext context,
                                        java.lang.String clientId)
Overrides:
convertClientId in class javax.faces.render.Renderer

decode

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

encodeEnd

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

getRendersChildren

public boolean getRendersChildren()
Overrides:
getRendersChildren in class javax.faces.render.Renderer

decodeBehaviors

protected final java.lang.String decodeBehaviors(javax.faces.context.FacesContext context,
                                                 javax.faces.component.UIComponent component)

isBehaviorSource

protected boolean isBehaviorSource(javax.faces.context.FacesContext ctx,
                                   java.lang.String behaviorSourceId,
                                   java.lang.String componentClientId)
Parameters:
ctx - the FacesContext for the current request
behaviorSourceId - the ID of the behavior source
componentClientId - the client ID of the component being decoded
Returns:
true if the behavior source is for the component being decoded, otherwise false

augmentIdReference

protected java.lang.String augmentIdReference(java.lang.String forValue,
                                              javax.faces.component.UIComponent fromComponent)

Conditionally augment an id-reference value.

If the forValue doesn't already include a generated suffix, but the id of the fromComponent does include a generated suffix, then append the suffix from the fromComponent to the forValue. Otherwise just return the forValue as is.

Parameters:
forValue - - the basic id-reference value.
fromComponent - - the component that holds the code>forValue.
Returns:
the (possibly augmented) forValue.

encodeRecursive

protected void encodeRecursive(javax.faces.context.FacesContext context,
                               javax.faces.component.UIComponent component)
                        throws java.io.IOException

Render nested child components by invoking the encode methods on those components, but only when the rendered property is true.

Parameters:
context - FacesContext for the current request
component - the component to recursively encode
Throws:
java.io.IOException - if an error occurrs during the encode process

getChildren

protected java.util.Iterator<javax.faces.component.UIComponent> getChildren(javax.faces.component.UIComponent component)
Parameters:
component - UIComponent for which to extract children
Returns:
an Iterator over the children of the specified component, selecting only those that have a rendered property of true.

getCurrentValue

protected java.lang.String getCurrentValue(javax.faces.context.FacesContext context,
                                           javax.faces.component.UIComponent component)
Parameters:
context - the FacesContext for the current request
component - the UIComponent whose value we're interested in
Returns:
the value to be rendered and formats it if required. Sets to empty string if value is null.

getEndTextToRender

protected void getEndTextToRender(javax.faces.context.FacesContext context,
                                  javax.faces.component.UIComponent component,
                                  java.lang.String currentValue)
                           throws java.io.IOException
Renderers override this method to write appropriate HTML content into the buffer.

Parameters:
context - the FacesContext for the current request
component - the UIComponent of interest
currentValue - component's current value
Throws:
java.io.IOException - if an error occurs rendering the text

getFacet

protected javax.faces.component.UIComponent getFacet(javax.faces.component.UIComponent component,
                                                     java.lang.String name)
Parameters:
component - Component from which to return a facet
name - Name of the desired facet
Returns:
the specified facet from the specified component, but only if its rendered property is set to true.

getForComponent

protected javax.faces.component.UIComponent getForComponent(javax.faces.context.FacesContext context,
                                                            java.lang.String forComponent,
                                                            javax.faces.component.UIComponent component)
Locates the component identified by forComponent

Parameters:
context - the FacesContext for the current request
forComponent - - the component to search for
component - - the starting point in which to begin the search
Returns:
the component with the the idforComponent otheriwse null if no match is found.

getFormattedValue

protected java.lang.String getFormattedValue(javax.faces.context.FacesContext context,
                                             javax.faces.component.UIComponent component,
                                             java.lang.Object currentValue,
                                             javax.faces.convert.Converter converter)
                                      throws javax.faces.convert.ConverterException
Overloads getFormattedValue to take a advantage of a previously obtained converter.

Parameters:
context - the FacesContext for the current request
component - UIComponent of interest
currentValue - the current value of component
converter - the component's converter
Returns:
the currentValue after any associated Converter has been applied
Throws:
javax.faces.convert.ConverterException - if the value cannot be converted

getFormattedValue

protected java.lang.String getFormattedValue(javax.faces.context.FacesContext context,
                                             javax.faces.component.UIComponent component,
                                             java.lang.Object currentValue)
                                      throws javax.faces.convert.ConverterException
Parameters:
context - the FacesContext for the current request
component - UIComponent of interest
currentValue - the current value of component
Returns:
the currentValue after any associated Converter has been applied
Throws:
javax.faces.convert.ConverterException - if the value cannot be converted

getMessageIter

protected java.util.Iterator getMessageIter(javax.faces.context.FacesContext context,
                                            java.lang.String forComponent,
                                            javax.faces.component.UIComponent component)

getParamList

protected HtmlBasicRenderer.Param[] getParamList(javax.faces.component.UIComponent command)
Parameters:
command - the command which may have parameters
Returns:
an array of parameters

getBehaviorParameters

protected java.util.Collection<javax.faces.component.behavior.ClientBehaviorContext.Parameter> getBehaviorParameters(javax.faces.component.UIComponent command)
Collections parameters for use with Behavior script rendering. Similar to getParamList(), but returns a collection of ClientBehaviorContext.Parameter instances.

Parameters:
command - the command which may have parameters
Returns:
a collection of ClientBehaviorContext.Parameter instances.

getValue

protected java.lang.Object getValue(javax.faces.component.UIComponent component)

setSubmittedValue

protected void setSubmittedValue(javax.faces.component.UIComponent component,
                                 java.lang.Object value)
Renderers override this method to store the previous value of the associated component.

Parameters:
component - the target component to which the submitted value will be set
value - the value to set

shouldWriteIdAttribute

protected boolean shouldWriteIdAttribute(javax.faces.component.UIComponent component)
Parameters:
component - the component of interest
Returns:
true if this renderer should render an id attribute.

writeIdAttributeIfNecessary

protected java.lang.String writeIdAttributeIfNecessary(javax.faces.context.FacesContext context,
                                                       javax.faces.context.ResponseWriter writer,
                                                       javax.faces.component.UIComponent component)

rendererParamsNotNull

protected void rendererParamsNotNull(javax.faces.context.FacesContext context,
                                     javax.faces.component.UIComponent component)

shouldEncode

protected boolean shouldEncode(javax.faces.component.UIComponent component)

shouldDecode

protected boolean shouldDecode(javax.faces.component.UIComponent component)

shouldEncodeChildren

protected boolean shouldEncodeChildren(javax.faces.component.UIComponent component)

getPassThruBehaviors

protected static java.util.Map<java.lang.String,java.util.List<javax.faces.component.behavior.ClientBehavior>> getPassThruBehaviors(javax.faces.component.UIComponent component,
                                                                                                                                    java.lang.String domEventName,
                                                                                                                                    java.lang.String componentEventName)
When rendering pass thru attributes, we need to take any attached Behaviors into account. The presence of a non-empty Behaviors map can cause us to switch from optimized pass thru attribute rendering to the unoptimized code path. However, in two very common cases - attaching action behaviors to commands and attaching value change behaviors to editable value holders - the behaviors map is populated with behaviors that are not handled by the pass thru attribute code - ie. the behaviors are handled locally by the renderer. In order to optimize such cases, we check to see whether the component's behaviors map actually contains behaviors only for these non-pass thru attributes. If so, we can pass a null behavior map into renderPassThruAttributes(), thus ensuring that we can take advantage of the optimized pass thru rendering logic. Note that in all cases where we use this method, we actually have two behavior events that we want to check for - a low-level/dom event (eg. "click", or "change") plus a high-level component event (eg. "action", or "valueChange").

Parameters:
component - the component that we are rendering
domEventName - the name of the dom-level event
componentEventName - the name of the component-level event


Copyright © 2011 Oracle America, Inc. All Rights Reserved.