org.ajax4jsf.renderkit
Class AjaxRendererUtils

java.lang.Object
  extended by org.ajax4jsf.renderkit.AjaxRendererUtils

public final class AjaxRendererUtils
extends java.lang.Object

Author:
shura

Some utilites for render AJAX components.


Field Summary
static java.lang.String AJAX_ABORT_ATTR
           
static java.lang.String AJAX_AREAS_RENDERED
           
static java.lang.String AJAX_COMPONENT_ID_PARAMETER
           
static java.lang.String AJAX_DELAY_ATTR
           
static java.lang.String AJAX_FUNCTION_NAME
          Name Javasript function for submit AJAX request
static java.lang.String AJAX_PROCESS_ATTRIBUTE
           
static java.lang.String AJAX_QUEUE_ATTR
           
static java.lang.String AJAX_REGIONS_ATTRIBUTE
           
static java.lang.String AJAX_SINGLE_ATTR
           
static java.lang.String AJAX_SINGLE_PARAMETER_NAME
           
static java.lang.String ALL
           
static java.lang.String BEHAVIOR_EVENT_PARAMETER
           
static java.lang.String DATA_ATTR_NAME
           
static java.lang.String EXTENSION_ID
           
static java.lang.String FORM
           
static java.util.Set<java.lang.String> GLOBAL_META_COMPONENTS
           
static java.lang.String LIMITRENDER_ATTR_NAME
          Attribute to keep
static java.lang.String NONE
           
static java.lang.String ONBEFOREDOMUPDATE_ATTR_NAME
          Attribute for keep JavaScript function name for call before updating DOM tree.
static java.lang.String ONBEGIN_ATTR_NAME
           
static java.lang.String ONCOMPLETE_ATTR_NAME
          Attribute for keep JavaScript function name for call after complete request.
static java.lang.String ONCOMPLETE_CONTENT_ID
          Attribute for keep JavaScript function name for call after complete request.
static java.lang.String REGION
           
static java.lang.String SIMILARITY_GROUPING_ID_ATTR
           
static java.lang.String STATUS_ATTR_NAME
          Attribute for keep clientId of status component
static java.lang.String THIS
           
static java.lang.String VALUE_ATTR
           
 
Method Summary
static void addRegionByName(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, java.lang.String id)
          TODO: add deprecation
static void addRegionsFromComponent(javax.faces.component.UIComponent component, javax.faces.context.FacesContext facesContext)
           
static java.lang.String[] asArray(java.lang.String valuesSet)
          Split parameter string into array of strings.
static java.util.Set<java.lang.String> asSet(java.lang.Object valueToSet)
          Convert parameter ( Collection, List, array, String, comma-separated String, whitespace-separate String) to set of strings.
static org.ajax4jsf.javascript.JSFunction buildAjaxFunction(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent, java.lang.String functionName)
          Create call to Ajax Submit function with first two parameters
static org.ajax4jsf.javascript.JSFunctionDefinition buildAjaxOnBeforeDomUpdate(java.lang.String body)
           
static org.ajax4jsf.javascript.JSFunctionDefinition buildAjaxOncomplete(java.lang.String body)
           
static AjaxEventOptions buildEventOptions(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
           
static AjaxEventOptions buildEventOptions(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, org.ajax4jsf.component.AjaxClientBehavior ajaxBehavior)
           
static java.lang.StringBuffer buildOnClick(javax.faces.component.UIComponent uiComponent, javax.faces.context.FacesContext facesContext)
          Build JavaScript onclick event for given component
static java.lang.StringBuffer buildOnClick(javax.faces.component.UIComponent uiComponent, javax.faces.context.FacesContext facesContext, boolean omitDefaultActionUrl)
          Build JavaScript onclick event for given component
static java.lang.StringBuffer buildOnEvent(javax.faces.component.UIComponent uiComponent, javax.faces.context.FacesContext facesContext, java.lang.String eventName)
          Build JavaScript event for component
static java.lang.StringBuffer buildOnEvent(javax.faces.component.UIComponent uiComponent, javax.faces.context.FacesContext facesContext, java.lang.String eventName, boolean omitDefaultActionUrl)
          Build JavaScript event for component
static void encodeAjaxBegin(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Encode declaration for AJAX response.
static void encodeAjaxEnd(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          End encoding of AJAX response.
static void encodeAreas(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
          Encode rendered areas as special HTML tag ( span in current release )
static org.ajax4jsf.component.AjaxContainer findAjaxContainer(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent uiComponent)
           
static java.lang.String getAbsoluteId(javax.faces.component.UIComponent component)
          Replacement for buggy in MyFaces RendererUtils
protected static java.lang.String getAjaxActionUrl(javax.faces.context.FacesContext facesContext)
           
static java.util.Set<java.lang.String> getAjaxAreas(javax.faces.component.UIComponent uiComponent)
          Get list of clientId's for given component
static java.util.Set<java.lang.String> getAjaxAreasToProcess(javax.faces.component.UIComponent component)
          Returns set of areas to be processed as a result of this component action invocation
static java.lang.Object getAjaxData(javax.faces.component.UIComponent component)
           
static java.lang.String getAjaxOnBeforeDomUpdate(javax.faces.component.UIComponent component)
          Get function name for call before update DOM.
static java.lang.String getAjaxOnBegin(javax.faces.component.UIComponent component)
           
static java.lang.String getAjaxOncomplete(javax.faces.component.UIComponent component)
          Get function name for call on completed ajax request.
static java.lang.String getAjaxStatus(javax.faces.component.UIComponent component)
          Get status area Id for given component.
static javax.faces.component.UIComponent getNestingForm(javax.faces.component.UIComponent component)
          Find nested form for given component
static boolean isAjaxLimitRender(javax.faces.component.UIComponent component)
          Calculate, must be component render only given areas, or all sended from server.
static boolean isAjaxRequest(javax.faces.context.FacesContext facesContext)
           
static void loadBundles(javax.faces.context.FacesContext context)
          Find all instances of UILoadBundle in view tree and load bundles to request-scope map.
static void renderAjaxExtensions(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
           
static void writeState(javax.faces.context.FacesContext context)
          Write state saving markers to context, include MyFaces view sequence.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

AJAX_ABORT_ATTR

public static final java.lang.String AJAX_ABORT_ATTR
See Also:
Constant Field Values

AJAX_AREAS_RENDERED

public static final java.lang.String AJAX_AREAS_RENDERED
See Also:
Constant Field Values

AJAX_DELAY_ATTR

public static final java.lang.String AJAX_DELAY_ATTR
See Also:
Constant Field Values

AJAX_FUNCTION_NAME

public static final java.lang.String AJAX_FUNCTION_NAME
Name Javasript function for submit AJAX request

See Also:
Constant Field Values

AJAX_PROCESS_ATTRIBUTE

public static final java.lang.String AJAX_PROCESS_ATTRIBUTE
Since:
3.3.0
See Also:
Constant Field Values

AJAX_QUEUE_ATTR

public static final java.lang.String AJAX_QUEUE_ATTR
See Also:
Constant Field Values

AJAX_REGIONS_ATTRIBUTE

public static final java.lang.String AJAX_REGIONS_ATTRIBUTE
See Also:
Constant Field Values

AJAX_SINGLE_ATTR

public static final java.lang.String AJAX_SINGLE_ATTR
See Also:
Constant Field Values

AJAX_SINGLE_PARAMETER_NAME

public static final java.lang.String AJAX_SINGLE_PARAMETER_NAME
See Also:
Constant Field Values

ALL

public static final java.lang.String ALL
See Also:
Constant Field Values

FORM

public static final java.lang.String FORM
See Also:
Constant Field Values

THIS

public static final java.lang.String THIS
See Also:
Constant Field Values

REGION

public static final java.lang.String REGION
See Also:
Constant Field Values

NONE

public static final java.lang.String NONE
See Also:
Constant Field Values

GLOBAL_META_COMPONENTS

public static final java.util.Set<java.lang.String> GLOBAL_META_COMPONENTS

LIMITRENDER_ATTR_NAME

public static final java.lang.String LIMITRENDER_ATTR_NAME
Attribute to keep

See Also:
Constant Field Values

ONBEFOREDOMUPDATE_ATTR_NAME

public static final java.lang.String ONBEFOREDOMUPDATE_ATTR_NAME
Attribute for keep JavaScript function name for call before updating DOM tree.

See Also:
Constant Field Values

ONBEGIN_ATTR_NAME

public static final java.lang.String ONBEGIN_ATTR_NAME
See Also:
Constant Field Values

ONCOMPLETE_ATTR_NAME

public static final java.lang.String ONCOMPLETE_ATTR_NAME
Attribute for keep JavaScript function name for call after complete request.

See Also:
Constant Field Values

DATA_ATTR_NAME

public static final java.lang.String DATA_ATTR_NAME
See Also:
Constant Field Values

ONCOMPLETE_CONTENT_ID

public static final java.lang.String ONCOMPLETE_CONTENT_ID
Attribute for keep JavaScript function name for call after complete request.

See Also:
Constant Field Values

SIMILARITY_GROUPING_ID_ATTR

public static final java.lang.String SIMILARITY_GROUPING_ID_ATTR
See Also:
Constant Field Values

STATUS_ATTR_NAME

public static final java.lang.String STATUS_ATTR_NAME
Attribute for keep clientId of status component

See Also:
Constant Field Values

VALUE_ATTR

public static final java.lang.String VALUE_ATTR
See Also:
Constant Field Values

EXTENSION_ID

public static final java.lang.String EXTENSION_ID
See Also:
Constant Field Values

AJAX_COMPONENT_ID_PARAMETER

public static final java.lang.String AJAX_COMPONENT_ID_PARAMETER
See Also:
Constant Field Values

BEHAVIOR_EVENT_PARAMETER

public static final java.lang.String BEHAVIOR_EVENT_PARAMETER
See Also:
Constant Field Values
Method Detail

buildOnClick

public static java.lang.StringBuffer buildOnClick(javax.faces.component.UIComponent uiComponent,
                                                  javax.faces.context.FacesContext facesContext)
Build JavaScript onclick event for given component

Parameters:
uiComponent - - component for build event
facesContext -
Returns:
StringBuffer with Javascript code

buildOnClick

public static java.lang.StringBuffer buildOnClick(javax.faces.component.UIComponent uiComponent,
                                                  javax.faces.context.FacesContext facesContext,
                                                  boolean omitDefaultActionUrl)
Build JavaScript onclick event for given component

Parameters:
uiComponent - - component for build event
facesContext -
omitDefaultActionUrl - - default action URL is not encoded if parameter is true
Returns:
StringBuffer with Javascript code

buildOnEvent

public static java.lang.StringBuffer buildOnEvent(javax.faces.component.UIComponent uiComponent,
                                                  javax.faces.context.FacesContext facesContext,
                                                  java.lang.String eventName)
Build JavaScript event for component

Parameters:
uiComponent - - component for build event
facesContext -
eventName - - name of event
Returns:
StringBuffer with Javascript code

buildOnEvent

public static java.lang.StringBuffer buildOnEvent(javax.faces.component.UIComponent uiComponent,
                                                  javax.faces.context.FacesContext facesContext,
                                                  java.lang.String eventName,
                                                  boolean omitDefaultActionUrl)
Build JavaScript event for component

Parameters:
uiComponent - - component for build event
facesContext -
eventName - - name of event
omitDefaultActionUrl - - default action URL is not encoded if parameter is true
Returns:
StringBuffer with Javascript code

buildEventOptions

public static AjaxEventOptions buildEventOptions(javax.faces.context.FacesContext facesContext,
                                                 javax.faces.component.UIComponent component)

buildEventOptions

public static AjaxEventOptions buildEventOptions(javax.faces.context.FacesContext facesContext,
                                                 javax.faces.component.UIComponent component,
                                                 org.ajax4jsf.component.AjaxClientBehavior ajaxBehavior)

buildAjaxFunction

public static org.ajax4jsf.javascript.JSFunction buildAjaxFunction(javax.faces.context.FacesContext facesContext,
                                                                   javax.faces.component.UIComponent uiComponent,
                                                                   java.lang.String functionName)
Create call to Ajax Submit function with first two parameters

Parameters:
facesContext -
uiComponent -
functionName -
Returns:

getAjaxAreas

public static java.util.Set<java.lang.String> getAjaxAreas(javax.faces.component.UIComponent uiComponent)
Get list of clientId's for given component

Parameters:
uiComponent -
Returns:
List of areas Id's , updated by this component.

getAjaxAreasToProcess

public static java.util.Set<java.lang.String> getAjaxAreasToProcess(javax.faces.component.UIComponent component)
Returns set of areas to be processed as a result of this component action invocation

Parameters:
component -
Returns:
set of IDs that should be processed as a
Since:
3.3.0

asArray

public static java.lang.String[] asArray(java.lang.String valuesSet)
Split parameter string into array of strings.

Parameters:
valuesSet -
Returns:

asSet

public static java.util.Set<java.lang.String> asSet(java.lang.Object valueToSet)
Convert parameter ( Collection, List, array, String, comma-separated String, whitespace-separate String) to set of strings.

Parameters:
valueToSet - - object for conversion to Set.
Returns:
- set of strings.

getAjaxStatus

public static java.lang.String getAjaxStatus(javax.faces.component.UIComponent component)
Get status area Id for given component.

Parameters:
component -
Returns:
clientId of status area, or null

buildAjaxOncomplete

public static org.ajax4jsf.javascript.JSFunctionDefinition buildAjaxOncomplete(java.lang.String body)

buildAjaxOnBeforeDomUpdate

public static org.ajax4jsf.javascript.JSFunctionDefinition buildAjaxOnBeforeDomUpdate(java.lang.String body)

getAjaxOncomplete

public static java.lang.String getAjaxOncomplete(javax.faces.component.UIComponent component)
Get function name for call on completed ajax request.

Parameters:
component - for wich calculate function name
Returns:
name of JavaScript function or null

getAjaxOnBeforeDomUpdate

public static java.lang.String getAjaxOnBeforeDomUpdate(javax.faces.component.UIComponent component)
Get function name for call before update DOM.

Parameters:
component - for wich calculate function name
Returns:
name of JavaScript function or null

getAjaxOnBegin

public static java.lang.String getAjaxOnBegin(javax.faces.component.UIComponent component)

getAjaxData

public static java.lang.Object getAjaxData(javax.faces.component.UIComponent component)
Parameters:
component -
Returns:
Since:
4.0

isAjaxLimitRender

public static boolean isAjaxLimitRender(javax.faces.component.UIComponent component)
Calculate, must be component render only given areas, or all sended from server.

Parameters:
component -
Returns:
true if client must render ONLY given areas.

getAbsoluteId

public static java.lang.String getAbsoluteId(javax.faces.component.UIComponent component)
Replacement for buggy in MyFaces RendererUtils

Parameters:
component -
Returns:

getNestingForm

public static javax.faces.component.UIComponent getNestingForm(javax.faces.component.UIComponent component)
Find nested form for given component

Parameters:
component -
Returns:
nested UIForm component, or null

getAjaxActionUrl

protected static java.lang.String getAjaxActionUrl(javax.faces.context.FacesContext facesContext)

findAjaxContainer

public static org.ajax4jsf.component.AjaxContainer findAjaxContainer(javax.faces.context.FacesContext facesContext,
                                                                     javax.faces.component.UIComponent uiComponent)
Parameters:
facesContext -
uiComponent -
Returns:

encodeAreas

public static void encodeAreas(javax.faces.context.FacesContext context,
                               javax.faces.component.UIComponent component)
                        throws java.io.IOException
Encode rendered areas as special HTML tag ( span in current release )

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

writeState

public static void writeState(javax.faces.context.FacesContext context)
                       throws java.io.IOException
Write state saving markers to context, include MyFaces view sequence.

Parameters:
context -
Throws:
java.io.IOException

encodeAjaxBegin

public static void encodeAjaxBegin(javax.faces.context.FacesContext context,
                                   javax.faces.component.UIComponent component)
                            throws java.io.IOException
Encode declaration for AJAX response. Render <html><body>

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

encodeAjaxEnd

public static void encodeAjaxEnd(javax.faces.context.FacesContext context,
                                 javax.faces.component.UIComponent component)
                          throws java.io.IOException
End encoding of AJAX response. Render tag with included areas and close </body></html>

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

loadBundles

public static void loadBundles(javax.faces.context.FacesContext context)
Find all instances of UILoadBundle in view tree and load bundles to request-scope map.

Parameters:
context -
Throws:
java.io.IOException

isAjaxRequest

public static boolean isAjaxRequest(javax.faces.context.FacesContext facesContext)
Parameters:
facesContext -
Returns:

addRegionByName

public static void addRegionByName(javax.faces.context.FacesContext facesContext,
                                   javax.faces.component.UIComponent component,
                                   java.lang.String id)
TODO: add deprecation

Parameters:
facesContext -
component -
id -

addRegionsFromComponent

public static void addRegionsFromComponent(javax.faces.component.UIComponent component,
                                           javax.faces.context.FacesContext facesContext)
Parameters:
facesContext -
component -

renderAjaxExtensions

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


Copyright © 2010 JBoss, a division of Red Hat, Inc.. All Rights Reserved.