org.jboss.seam.ui.util.cdk
Class RendererUtils

java.lang.Object
  extended by org.jboss.seam.ui.util.cdk.RendererUtils

public class RendererUtils
extends java.lang.Object

Util class for common render operations - render passthru html attributes, iterate over child components etc.

Author:
asmirnov@exadel.com (latest modification by $Author: gavin $)

Nested Class Summary
static interface RendererUtils.HTML
          Common HTML elements and attributes names.
 
Field Summary
static java.lang.String DUMMY_FORM_ID
           
 
Constructor Summary
RendererUtils()
           
 
Method Summary
protected  java.lang.Object attributeValue(java.lang.String name, java.lang.Object value)
          Convert attribute value to proper object.
 java.lang.String clientId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Simplified version of encodeId()
 void encodeAttribute(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object property, java.lang.String attributeName)
           
 void encodeAttribute(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String attribute)
           
 void encodeAttributes(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String attrs)
          Encode attributes given by comma-separated string list.
 void encodeAttributesFromArray(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String[] attrs)
           
 void encodeBeginForm(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, javax.faces.context.ResponseWriter writer, java.lang.String clientId)
           
 void encodeBeginFormIfNessesary(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
 void encodeCustomId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Encode id attribute with clientId component property.
 void encodeEndForm(javax.faces.context.FacesContext context, javax.faces.context.ResponseWriter writer)
           
 void encodeEndFormIfNessesary(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
 void encodeId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Encode id attribute with clientId component property
 void encodeId(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String attribute)
          Encode clientId to custom attribute ( for example, to control name )
 void encodePassThru(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Encode common pass-thru html attributes.
 void encodePassThruAttribute(javax.faces.context.FacesContext context, java.util.Map attributes, javax.faces.context.ResponseWriter writer, java.lang.String attribute)
          Encode one pass-thru attribute, with plain/boolean/url value, got from properly component attribute.
 void encodePassThruWithExclusions(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String exclusions)
          Encode pass-through attributes except specified ones
 void encodePassThruWithExclusionsArray(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.String[] exclusions)
           
 java.lang.String formatValue(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object value)
          Convert any object value to string.
 java.lang.String getActionUrl(javax.faces.context.FacesContext facesContext)
           
protected  java.lang.Object getComponentAttributeName(java.lang.Object key)
          Convert HTML attribute name to component property name.
 javax.faces.component.UIForm getNestingForm(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Find nested form for given component
 java.lang.String getValueAsString(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Return converted value for ValueHolder as String, perform nessesary convertions.
 boolean isBooleanAttribute(javax.faces.component.UIComponent component, java.lang.String name)
          Get boolean value of logical attribute
 boolean isValidProperty(java.lang.Object property)
          Test for valid value of property.
 boolean shouldRenderAttribute(java.lang.Object attributeVal)
           
 void writeAttribute(javax.faces.context.ResponseWriter writer, java.lang.String attribute, java.lang.Object value)
          Write html-attribute
 void writeScript(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component, java.lang.Object script)
          Wtrie JavaScript with start/end elements and type.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DUMMY_FORM_ID

public static final java.lang.String DUMMY_FORM_ID
See Also:
Constant Field Values
Constructor Detail

RendererUtils

public RendererUtils()
Method Detail

encodeId

public void encodeId(javax.faces.context.FacesContext context,
                     javax.faces.component.UIComponent component)
              throws java.io.IOException
Encode id attribute with clientId component property

Throws:
java.io.IOException

encodeId

public void encodeId(javax.faces.context.FacesContext context,
                     javax.faces.component.UIComponent component,
                     java.lang.String attribute)
              throws java.io.IOException
Encode clientId to custom attribute ( for example, to control name )

Throws:
java.io.IOException

encodeCustomId

public void encodeCustomId(javax.faces.context.FacesContext context,
                           javax.faces.component.UIComponent component)
                    throws java.io.IOException
Encode id attribute with clientId component property. Encoded only if id not auto generated.

Throws:
java.io.IOException

encodePassThru

public void encodePassThru(javax.faces.context.FacesContext context,
                           javax.faces.component.UIComponent component)
                    throws java.io.IOException
Encode common pass-thru html attributes.

Throws:
java.io.IOException

encodePassThruWithExclusions

public void encodePassThruWithExclusions(javax.faces.context.FacesContext context,
                                         javax.faces.component.UIComponent component,
                                         java.lang.String exclusions)
                                  throws java.io.IOException
Encode pass-through attributes except specified ones

Parameters:
context -
component -
exclusions -
Throws:
java.io.IOException

encodePassThruWithExclusionsArray

public void encodePassThruWithExclusionsArray(javax.faces.context.FacesContext context,
                                              javax.faces.component.UIComponent component,
                                              java.lang.String[] exclusions)
                                       throws java.io.IOException
Throws:
java.io.IOException

encodePassThruAttribute

public void encodePassThruAttribute(javax.faces.context.FacesContext context,
                                    java.util.Map attributes,
                                    javax.faces.context.ResponseWriter writer,
                                    java.lang.String attribute)
                             throws java.io.IOException
Encode one pass-thru attribute, with plain/boolean/url value, got from properly component attribute.

Throws:
java.io.IOException

encodeAttributesFromArray

public void encodeAttributesFromArray(javax.faces.context.FacesContext context,
                                      javax.faces.component.UIComponent component,
                                      java.lang.String[] attrs)
                               throws java.io.IOException
Throws:
java.io.IOException

encodeAttributes

public void encodeAttributes(javax.faces.context.FacesContext context,
                             javax.faces.component.UIComponent component,
                             java.lang.String attrs)
                      throws java.io.IOException
Encode attributes given by comma-separated string list.

Parameters:
context - current JSF context
component - for with render attributes values
attrs - comma separated list of attributes
Throws:
java.io.IOException

encodeAttribute

public void encodeAttribute(javax.faces.context.FacesContext context,
                            javax.faces.component.UIComponent component,
                            java.lang.Object property,
                            java.lang.String attributeName)
                     throws java.io.IOException
Throws:
java.io.IOException

encodeAttribute

public void encodeAttribute(javax.faces.context.FacesContext context,
                            javax.faces.component.UIComponent component,
                            java.lang.String attribute)
                     throws java.io.IOException
Throws:
java.io.IOException

writeAttribute

public void writeAttribute(javax.faces.context.ResponseWriter writer,
                           java.lang.String attribute,
                           java.lang.Object value)
                    throws java.io.IOException
Write html-attribute

Parameters:
writer -
attribute -
value -
Throws:
java.io.IOException

shouldRenderAttribute

public boolean shouldRenderAttribute(java.lang.Object attributeVal)
Returns:
true if and only if the argument attributeVal is an instance of a wrapper for a primitive type and its value is equal to the default value for that type as given in the spec.

isValidProperty

public boolean isValidProperty(java.lang.Object property)
Test for valid value of property. by default, for non-setted properties with Java primitive types of JSF component return appropriate MIN_VALUE .

Parameters:
property - - value of property returned from UIComponent.getAttributes()
Returns:
true for setted property, false otherthise.

getComponentAttributeName

protected java.lang.Object getComponentAttributeName(java.lang.Object key)
Convert HTML attribute name to component property name.


attributeValue

protected java.lang.Object attributeValue(java.lang.String name,
                                          java.lang.Object value)
Convert attribute value to proper object. For known html boolean attributes return name for true value, otherthise - null. For non-boolean attributes return same value.

Parameters:
name - attribute name

isBooleanAttribute

public boolean isBooleanAttribute(javax.faces.component.UIComponent component,
                                  java.lang.String name)
Get boolean value of logical attribute

Parameters:
component -
name - attribute name
Returns:
true if attribute is equals Boolean.TRUE or String "true" , false otherwise.

getValueAsString

public java.lang.String getValueAsString(javax.faces.context.FacesContext context,
                                         javax.faces.component.UIComponent component)
Return converted value for ValueHolder as String, perform nessesary convertions.


formatValue

public java.lang.String formatValue(javax.faces.context.FacesContext context,
                                    javax.faces.component.UIComponent component,
                                    java.lang.Object value)
Convert any object value to string. If component instance of ValueHolder got Converter for formatting. If not, attempt to use converter based on value type.


getNestingForm

public javax.faces.component.UIForm getNestingForm(javax.faces.context.FacesContext context,
                                                   javax.faces.component.UIComponent component)
Find nested form for given component

Returns:
nested UIForm component, or null

encodeBeginFormIfNessesary

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

encodeBeginForm

public void encodeBeginForm(javax.faces.context.FacesContext context,
                            javax.faces.component.UIComponent component,
                            javax.faces.context.ResponseWriter writer,
                            java.lang.String clientId)
                     throws java.io.IOException
Throws:
java.io.IOException

encodeEndFormIfNessesary

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

encodeEndForm

public void encodeEndForm(javax.faces.context.FacesContext context,
                          javax.faces.context.ResponseWriter writer)
                   throws java.io.IOException
Throws:
java.io.IOException

getActionUrl

public java.lang.String getActionUrl(javax.faces.context.FacesContext facesContext)
Returns:
String A String representing the action URL

clientId

public java.lang.String clientId(javax.faces.context.FacesContext context,
                                 javax.faces.component.UIComponent component)
Simplified version of encodeId()

Returns:
client id of current component

writeScript

public void writeScript(javax.faces.context.FacesContext context,
                        javax.faces.component.UIComponent component,
                        java.lang.Object script)
                 throws java.io.IOException
Wtrie JavaScript with start/end elements and type.

Throws:
java.io.IOException


Copyright © 2007. All Rights Reserved.