org.apache.myfaces.tobago.util
Class ComponentUtils

java.lang.Object
  extended by org.apache.myfaces.tobago.util.ComponentUtils

public class ComponentUtils
extends Object


Field Summary
static Class[] ACTION_ARGS
           
static Class[] ACTION_LISTENER_ARGS
           
static String DATA_ATTRIBUTES_KEY
          PRELIMINARY - SUBJECT TO CHANGE Name of the map for data attributes in components.
static String LIST_SEPARATOR_CHARS
           
static String SUB_SEPARATOR
           
static Class[] VALIDATOR_ARGS
           
static Class[] VALUE_CHANGE_LISTENER_ARGS
           
 
Method Summary
static void addCurrentMarkup(SupportsMarkup component, Markup markup)
           
static boolean containsPopupActionListener(javax.faces.component.UICommand command)
           
static javax.faces.event.ActionListener createActionListener(String type)
           
static String createPickerId(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, String postfix)
           
static javax.faces.el.ValueBinding createValueBinding(String value)
           
static void evaluateAutoFor(javax.faces.component.UIComponent component)
          Deprecated.  
static void evaluateAutoFor(javax.faces.component.UIComponent component, Class<? extends javax.faces.component.UIComponent> clazz)
          Looks for the attribute "for" of the component.
static
<T> T
findAncestor(javax.faces.component.UIComponent component, Class<T> type)
           
static String findClientIdFor(javax.faces.component.UIComponent component, javax.faces.context.FacesContext facesContext)
          Looks for the attribute "for" in the component.
static javax.faces.component.UIComponent findComponent(javax.faces.component.UIComponent from, String relativeId)
          The search depends on the number of colons in the relativeId: colonCount == 0 fully relative colonCount == 1 absolute (still normal findComponent syntax) colonCount > 1 for each extra colon after 1, go up a naming container (to the view root, if naming containers run out)
static
<T extends javax.faces.component.UIComponent>
T
findDescendant(javax.faces.component.UIComponent component, Class<T> type)
          Searches the component tree beneath the component and return the first component matching the type.
static javax.faces.component.UIComponent findFor(javax.faces.component.UIComponent component)
           
static AbstractUIForm findForm(javax.faces.component.UIComponent component)
           
static AbstractUIPage findPage(javax.faces.context.FacesContext facesContext)
           
static AbstractUIPage findPage(javax.faces.context.FacesContext context, javax.faces.component.UIComponent component)
           
static AbstractUIPage findPage(javax.faces.component.UIComponent component)
           
static Object findParameter(javax.faces.component.UIComponent component, String name)
           
static List<AbstractUIForm> findSubForms(javax.faces.component.UIComponent component)
          Find all sub forms of a component, and collects it.
static Object getAttribute(javax.faces.component.UIComponent component, String name)
           
static boolean getBooleanAttribute(javax.faces.component.UIComponent component, String name)
           
static Character getCharacterAttribute(javax.faces.component.UIComponent component, String name)
           
static String[] getChildrenWithMessages(javax.faces.context.FacesContext facesContext, javax.faces.component.NamingContainer container)
           
static String getComponentId(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
           
static Object getConvertedValue(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component, String stringValue)
           
static Map<Object,Object> getDataAttributes(javax.faces.component.UIComponent component)
           
static String getFacesMessageAsString(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
           
static javax.faces.component.UIGraphic getFirstGraphicChild(javax.faces.component.UIComponent component)
           
static javax.faces.component.UIOutput getFirstNonGraphicChild(javax.faces.component.UIComponent component)
           
static int getIntAttribute(javax.faces.component.UIComponent component, String name)
           
static int getIntAttribute(javax.faces.component.UIComponent component, String name, int defaultValue)
           
static int getIntValue(javax.faces.el.ValueBinding valueBinding)
           
static String[] getMarkupBinding(javax.faces.context.FacesContext facesContext, SupportsMarkup component)
          Deprecated. since 1.5
static javax.faces.application.FacesMessage.Severity getMaximumSeverity(javax.faces.component.UIComponent component)
           
static javax.faces.application.FacesMessage.Severity getMaximumSeverityOfChildrenMessages(javax.faces.context.FacesContext facesContext, javax.faces.component.NamingContainer container)
           
static Object getObjectAttribute(javax.faces.component.UIComponent component, String name)
           
static RendererBase getRenderer(javax.faces.context.FacesContext facesContext, String family, String rendererType)
           
static RendererBase getRenderer(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
           
static String getStringAttribute(javax.faces.component.UIComponent component, String name)
           
static boolean hasChildrenWithMessages(javax.faces.context.FacesContext facesContext, javax.faces.component.NamingContainer container)
           
static boolean hasErrorMessages(javax.faces.context.FacesContext context)
           
static boolean hasSelectedValue(List<javax.faces.model.SelectItem> items, Object value)
           
static boolean isError(javax.faces.component.UIComponent component)
           
static boolean isError(javax.faces.component.UIInput uiInput)
           
static boolean isFacetOf(javax.faces.component.UIComponent component, javax.faces.component.UIComponent parent)
           
static boolean isHoverEnabled(javax.faces.component.UIComponent component)
           
static boolean isInActiveForm(javax.faces.component.UIComponent component)
           
static boolean isInPopup(javax.faces.component.UIComponent component)
           
static boolean isOutputOnly(javax.faces.component.UIComponent component)
           
static Markup markupOfSeverity(javax.faces.application.FacesMessage.Severity maximumSeverity)
           
static boolean mayUpdateModel(javax.faces.component.UIComponent component)
           
static boolean mayValidate(javax.faces.component.UIComponent component)
           
static javax.faces.component.UIComponent provideLabel(javax.faces.context.FacesContext facesContext, javax.faces.component.UIComponent component)
          Checks if the Component has a label facet and if not creates one with the label attribute.
static void putDataAttribute(javax.faces.component.UIComponent component, Object name, Object value)
          PRELIMINARY - SUBJECT TO CHANGE Adding a data attribute to the component.
static void putDataAttributeWithPrefix(javax.faces.component.UIComponent component, String name, Object value)
          PRELIMINARY - SUBJECT TO CHANGE Adding a data attribute to the component.
static String removePx(String value)
           
static void resetPage(javax.faces.context.FacesContext context)
           
static void setAction(javax.faces.component.ActionSource component, String action)
          Deprecated. since 1.5.0
static void setActionListener(javax.faces.component.ActionSource command, String actionListener)
          Deprecated. since 1.5.0
static void setConverter(javax.faces.component.ValueHolder valueHolder, String converterId)
          Deprecated. since 1.5.0
static void setIntegerSizeProperty(javax.faces.component.UIComponent component, String name, String value)
          Deprecated. since 1.5.0
static void setMarkup(javax.faces.component.UIComponent markupComponent, String markup)
          Deprecated. since 1.5.0
static void setStyleClasses(javax.faces.component.UIComponent component, String styleClasses)
          Deprecated. Please define a Markup and set it to the component with SupportsMarkup.setMarkup(Markup markup) before the rendering phase.
static void setValidator(javax.faces.component.EditableValueHolder editableValueHolder, String validator)
          Deprecated. since 1.5.0
static void setValueBinding(javax.faces.component.UIComponent component, String name, String state)
          Deprecated. since 1.5.0
static void setValueChangeListener(javax.faces.component.EditableValueHolder valueHolder, String valueChangeListener)
          Deprecated. since 1.5.0
static void setValueForValueBinding(String name, Object value)
           
static String[] splitList(String renderers)
           
static Markup updateMarkup(javax.faces.component.UIComponent component, Markup markup)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SUB_SEPARATOR

public static final String SUB_SEPARATOR
See Also:
Constant Field Values

ACTION_ARGS

public static final Class[] ACTION_ARGS

ACTION_LISTENER_ARGS

public static final Class[] ACTION_LISTENER_ARGS

VALUE_CHANGE_LISTENER_ARGS

public static final Class[] VALUE_CHANGE_LISTENER_ARGS

VALIDATOR_ARGS

public static final Class[] VALIDATOR_ARGS

LIST_SEPARATOR_CHARS

public static final String LIST_SEPARATOR_CHARS
See Also:
Constant Field Values

DATA_ATTRIBUTES_KEY

public static final String DATA_ATTRIBUTES_KEY
PRELIMINARY - SUBJECT TO CHANGE Name of the map for data attributes in components. New in JSF 2.2.

Since:
1.6.0
See Also:
Constant Field Values
Method Detail

hasErrorMessages

public static boolean hasErrorMessages(javax.faces.context.FacesContext context)

containsPopupActionListener

public static boolean containsPopupActionListener(javax.faces.component.UICommand command)

getFacesMessageAsString

public static String getFacesMessageAsString(javax.faces.context.FacesContext facesContext,
                                             javax.faces.component.UIComponent component)

isInPopup

public static boolean isInPopup(javax.faces.component.UIComponent component)

resetPage

public static void resetPage(javax.faces.context.FacesContext context)

findPage

public static AbstractUIPage findPage(javax.faces.context.FacesContext context,
                                      javax.faces.component.UIComponent component)

findPage

public static AbstractUIPage findPage(javax.faces.component.UIComponent component)

findPage

public static AbstractUIPage findPage(javax.faces.context.FacesContext facesContext)

findForm

public static AbstractUIForm findForm(javax.faces.component.UIComponent component)

findAncestor

public static <T> T findAncestor(javax.faces.component.UIComponent component,
                                 Class<T> type)

findSubForms

public static List<AbstractUIForm> findSubForms(javax.faces.component.UIComponent component)
Find all sub forms of a component, and collects it. It does not find sub forms of sub forms.


findDescendant

public static <T extends javax.faces.component.UIComponent> T findDescendant(javax.faces.component.UIComponent component,
                                                                             Class<T> type)
Searches the component tree beneath the component and return the first component matching the type.


findClientIdFor

public static String findClientIdFor(javax.faces.component.UIComponent component,
                                     javax.faces.context.FacesContext facesContext)
Looks for the attribute "for" in the component. If there is any search for the component which is referenced by the "for" attribute, and return their clientId. If there is no "for" attribute, return the "clientId" of the parent (if it has a parent). This is useful for labels.


findFor

public static javax.faces.component.UIComponent findFor(javax.faces.component.UIComponent component)

evaluateAutoFor

@Deprecated
public static void evaluateAutoFor(javax.faces.component.UIComponent component)
Deprecated. 

Looks for the attribute "for" of the component. In case that the value is equals to "@auto" the children of the parent will be checked if they are a UIInput. The "id" of the first one will be used to reset the "for" attribute of the component.


evaluateAutoFor

public static void evaluateAutoFor(javax.faces.component.UIComponent component,
                                   Class<? extends javax.faces.component.UIComponent> clazz)
Looks for the attribute "for" of the component. In case that the value is equals to "@auto" the children of the parent will be checked if they are of the type of the parameter clazz. The "id" of the first one will be used to reset the "for" attribute of the component.


isInActiveForm

public static boolean isInActiveForm(javax.faces.component.UIComponent component)

getMaximumSeverity

public static javax.faces.application.FacesMessage.Severity getMaximumSeverity(javax.faces.component.UIComponent component)

isError

public static boolean isError(javax.faces.component.UIInput uiInput)

isError

public static boolean isError(javax.faces.component.UIComponent component)

isOutputOnly

public static boolean isOutputOnly(javax.faces.component.UIComponent component)

mayValidate

public static boolean mayValidate(javax.faces.component.UIComponent component)

mayUpdateModel

public static boolean mayUpdateModel(javax.faces.component.UIComponent component)

getBooleanAttribute

public static boolean getBooleanAttribute(javax.faces.component.UIComponent component,
                                          String name)

createValueBinding

public static javax.faces.el.ValueBinding createValueBinding(String value)

setStyleClasses

@Deprecated
public static void setStyleClasses(javax.faces.component.UIComponent component,
                                              String styleClasses)
Deprecated. Please define a Markup and set it to the component with SupportsMarkup.setMarkup(Markup markup) before the rendering phase.


setMarkup

@Deprecated
public static void setMarkup(javax.faces.component.UIComponent markupComponent,
                                        String markup)
Deprecated. since 1.5.0


getAttribute

public static Object getAttribute(javax.faces.component.UIComponent component,
                                  String name)

getObjectAttribute

public static Object getObjectAttribute(javax.faces.component.UIComponent component,
                                        String name)

getStringAttribute

public static String getStringAttribute(javax.faces.component.UIComponent component,
                                        String name)

getIntAttribute

public static int getIntAttribute(javax.faces.component.UIComponent component,
                                  String name)

getIntAttribute

public static int getIntAttribute(javax.faces.component.UIComponent component,
                                  String name,
                                  int defaultValue)

getCharacterAttribute

public static Character getCharacterAttribute(javax.faces.component.UIComponent component,
                                              String name)

isFacetOf

public static boolean isFacetOf(javax.faces.component.UIComponent component,
                                javax.faces.component.UIComponent parent)

getRenderer

public static RendererBase getRenderer(javax.faces.context.FacesContext facesContext,
                                       javax.faces.component.UIComponent component)

getRenderer

public static RendererBase getRenderer(javax.faces.context.FacesContext facesContext,
                                       String family,
                                       String rendererType)

findParameter

public static Object findParameter(javax.faces.component.UIComponent component,
                                   String name)

createActionListener

public static javax.faces.event.ActionListener createActionListener(String type)
                                                             throws javax.servlet.jsp.JspException
Throws:
javax.servlet.jsp.JspException

getFirstGraphicChild

public static javax.faces.component.UIGraphic getFirstGraphicChild(javax.faces.component.UIComponent component)

isHoverEnabled

public static boolean isHoverEnabled(javax.faces.component.UIComponent component)

getFirstNonGraphicChild

public static javax.faces.component.UIOutput getFirstNonGraphicChild(javax.faces.component.UIComponent component)

setIntegerSizeProperty

@Deprecated
public static void setIntegerSizeProperty(javax.faces.component.UIComponent component,
                                                     String name,
                                                     String value)
Deprecated. since 1.5.0


removePx

public static String removePx(String value)

setValueForValueBinding

public static void setValueForValueBinding(String name,
                                           Object value)

hasSelectedValue

public static boolean hasSelectedValue(List<javax.faces.model.SelectItem> items,
                                       Object value)

getIntValue

public static int getIntValue(javax.faces.el.ValueBinding valueBinding)

createPickerId

public static String createPickerId(javax.faces.context.FacesContext facesContext,
                                    javax.faces.component.UIComponent component,
                                    String postfix)

getComponentId

public static String getComponentId(javax.faces.context.FacesContext facesContext,
                                    javax.faces.component.UIComponent component)

provideLabel

public static javax.faces.component.UIComponent provideLabel(javax.faces.context.FacesContext facesContext,
                                                             javax.faces.component.UIComponent component)
Checks if the Component has a label facet and if not creates one with the label attribute. Todo: check if this method should be set to deprecated.


setValidator

@Deprecated
public static void setValidator(javax.faces.component.EditableValueHolder editableValueHolder,
                                           String validator)
Deprecated. since 1.5.0


setConverter

@Deprecated
public static void setConverter(javax.faces.component.ValueHolder valueHolder,
                                           String converterId)
Deprecated. since 1.5.0


setAction

@Deprecated
public static void setAction(javax.faces.component.ActionSource component,
                                        String action)
Deprecated. since 1.5.0


setActionListener

@Deprecated
public static void setActionListener(javax.faces.component.ActionSource command,
                                                String actionListener)
Deprecated. since 1.5.0


setValueChangeListener

@Deprecated
public static void setValueChangeListener(javax.faces.component.EditableValueHolder valueHolder,
                                                     String valueChangeListener)
Deprecated. since 1.5.0


setValueBinding

@Deprecated
public static void setValueBinding(javax.faces.component.UIComponent component,
                                              String name,
                                              String state)
Deprecated. since 1.5.0


getMarkupBinding

@Deprecated
public static String[] getMarkupBinding(javax.faces.context.FacesContext facesContext,
                                                   SupportsMarkup component)
Deprecated. since 1.5


findComponent

public static javax.faces.component.UIComponent findComponent(javax.faces.component.UIComponent from,
                                                              String relativeId)
The search depends on the number of colons in the relativeId:
colonCount == 0
fully relative
colonCount == 1
absolute (still normal findComponent syntax)
colonCount > 1
for each extra colon after 1, go up a naming container
(to the view root, if naming containers run out)


splitList

public static String[] splitList(String renderers)

getConvertedValue

public static Object getConvertedValue(javax.faces.context.FacesContext facesContext,
                                       javax.faces.component.UIComponent component,
                                       String stringValue)

updateMarkup

public static Markup updateMarkup(javax.faces.component.UIComponent component,
                                  Markup markup)

markupOfSeverity

public static Markup markupOfSeverity(javax.faces.application.FacesMessage.Severity maximumSeverity)

addCurrentMarkup

public static void addCurrentMarkup(SupportsMarkup component,
                                    Markup markup)

hasChildrenWithMessages

public static boolean hasChildrenWithMessages(javax.faces.context.FacesContext facesContext,
                                              javax.faces.component.NamingContainer container)

getMaximumSeverityOfChildrenMessages

public static javax.faces.application.FacesMessage.Severity getMaximumSeverityOfChildrenMessages(javax.faces.context.FacesContext facesContext,
                                                                                                 javax.faces.component.NamingContainer container)

getChildrenWithMessages

public static String[] getChildrenWithMessages(javax.faces.context.FacesContext facesContext,
                                               javax.faces.component.NamingContainer container)

putDataAttributeWithPrefix

public static void putDataAttributeWithPrefix(javax.faces.component.UIComponent component,
                                              String name,
                                              Object value)
PRELIMINARY - SUBJECT TO CHANGE Adding a data attribute to the component. The name must start with "data-", e. g. "data-tobago-foo" or "data-bar"


putDataAttribute

public static void putDataAttribute(javax.faces.component.UIComponent component,
                                    Object name,
                                    Object value)
PRELIMINARY - SUBJECT TO CHANGE Adding a data attribute to the component. The name should not start with "data-", e. g. "tobago-foo" or "bar"


getDataAttributes

public static Map<Object,Object> getDataAttributes(javax.faces.component.UIComponent component)


Copyright © 2002-2014 The Apache Software Foundation. All Rights Reserved.