org.rhq.core.gui.util
Class FacesComponentUtility

java.lang.Object
  extended by org.rhq.core.gui.util.FacesComponentUtility

public abstract class FacesComponentUtility
extends Object

A set of utility methods for working with JSF UIComponents.

Author:
Ian Springer

Field Summary
static String NO_STYLE_CLASS
           
 
Constructor Summary
FacesComponentUtility()
           
 
Method Summary
static javax.faces.component.html.HtmlPanelGroup addBlockPanel(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, String styleClass)
           
static javax.faces.component.UIOutput addButton(javax.faces.component.UIComponent parent, String label, String styleClass)
           
static javax.faces.component.html.HtmlColumn addColumn(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, CharSequence headerText, String headerStyle)
           
static javax.faces.component.html.HtmlCommandButton addCommandButton(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, String value, String styleClass)
           
static javax.faces.component.html.HtmlCommandLink addCommandLink(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory)
           
static javax.faces.component.html.HtmlDataTable addDataTable(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, String styleClass)
           
static javax.faces.component.html.HtmlForm addForm(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory)
           
static javax.faces.component.html.HtmlGraphicImage addGraphicImage(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, String url, String alt)
           
static javax.faces.component.html.HtmlPanelGroup addInlinePanel(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, String styleClass)
           
static javax.faces.component.UIOutput addJavaScript(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, CharSequence src, CharSequence script)
           
static javax.faces.component.html.HtmlOutputLabel addLabel(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, javax.faces.component.UIInput associatedInput, String value, String styleClass)
           
static javax.faces.component.html.HtmlMessage addMessage(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, String associatedComponentId, String styleClass)
           
static javax.faces.component.html.HtmlOutputLink addOutputLink(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, String value)
           
static javax.faces.component.html.HtmlOutputText addOutputText(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, CharSequence value, String styleClass)
           
static javax.faces.component.html.HtmlPanelGrid addPanelGrid(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, int columns, String styleClass)
           
static javax.faces.component.UIParameter addParameter(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, String name, String value)
           
static org.richfaces.component.html.HtmlSeparator addSeparator(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory)
           
static org.richfaces.component.html.HtmlSimpleTogglePanel addSimpleTogglePanel(javax.faces.component.UIComponent parent, FacesComponentIdFactory idFactory, String label)
           
static javax.faces.component.html.HtmlOutputText addVerbatimText(javax.faces.component.UIComponent parent, CharSequence html)
           
static javax.faces.component.html.HtmlPanelGroup createBlockPanel(FacesComponentIdFactory idFactory, String styleClass)
           
static
<T extends javax.faces.component.UIComponent>
T
createComponent(Class<T> componentClass)
          Creates a UIComponent of the specified type.
static
<T extends javax.faces.component.UIComponent>
T
createComponent(Class<T> componentClass, FacesComponentIdFactory idFactory)
          Creates a UIComponent of the specified type.
static javax.faces.component.html.HtmlOutputText createOutputText(FacesComponentIdFactory idFactory, CharSequence value, String styleClass)
           
static void detachComponent(javax.faces.component.UIComponent component)
          Removes the specified component from its parent if it has one.
static
<T extends javax.faces.component.UIComponent>
T
getAncestorOfType(javax.faces.component.UIComponent component, Class<T> componentClass)
           
static
<T extends javax.faces.component.UIComponent>
List<T>
getDescendantsOfType(javax.faces.component.UIComponent component, Class<T> componentClass)
           
static javax.faces.component.UIForm getEnclosingForm(javax.faces.component.UIComponent component)
          Returns the enclosing UIForm component, if any, from the specified component's ancestry.
static String getExpressionAttribute(javax.faces.component.UIComponent component, String attribName)
           
static
<T> T
getExpressionAttribute(javax.faces.component.UIComponent component, String attribName, Class<T> expectedType)
           
static Map<String,String> getParameters(javax.faces.component.UIComponent component)
           
static boolean isDisabled(javax.faces.component.UIComponent component)
          Gets the value of the "disabled" attribute on the specified component, or false if the component does not expose the attribute.
static boolean isOverride(javax.faces.component.UIComponent component)
           
static boolean isReadonly(javax.faces.component.UIComponent component)
          Gets the value of the "readonly" attribute on the specified component, or false if the component does not expose the attribute.
static boolean isUnset(javax.faces.component.UIComponent component)
          Gets the value of the "unset" attribute on the specified component, or false if the component does not expose the attribute.
static void setDisabled(javax.faces.component.UIComponent component, boolean disabled)
          Sets the "disabled" attribute on the specified component to the provided value.
static void setOverride(javax.faces.component.UIInput input, boolean override)
           
static void setReadonly(javax.faces.component.UIInput input, boolean readonly)
          Sets the "readonly" attribute on the specified component to the provided value.
static void setUnset(javax.faces.component.UIInput input, boolean unset)
          Sets the "unset" attribute on the specified component to the provided value.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

NO_STYLE_CLASS

public static final String NO_STYLE_CLASS
Constructor Detail

FacesComponentUtility

public FacesComponentUtility()
Method Detail

createBlockPanel

@NotNull
public static javax.faces.component.html.HtmlPanelGroup createBlockPanel(FacesComponentIdFactory idFactory,
                                                                                 String styleClass)

addBlockPanel

@NotNull
public static javax.faces.component.html.HtmlPanelGroup addBlockPanel(@NotNull
                                                                              javax.faces.component.UIComponent parent,
                                                                              FacesComponentIdFactory idFactory,
                                                                              String styleClass)

addInlinePanel

@NotNull
public static javax.faces.component.html.HtmlPanelGroup addInlinePanel(@NotNull
                                                                               javax.faces.component.UIComponent parent,
                                                                               FacesComponentIdFactory idFactory,
                                                                               String styleClass)

addSimpleTogglePanel

@NotNull
public static org.richfaces.component.html.HtmlSimpleTogglePanel addSimpleTogglePanel(@NotNull
                                                                                              javax.faces.component.UIComponent parent,
                                                                                              FacesComponentIdFactory idFactory,
                                                                                              String label)

addSeparator

@NotNull
public static org.richfaces.component.html.HtmlSeparator addSeparator(@NotNull
                                                                              javax.faces.component.UIComponent parent,
                                                                              FacesComponentIdFactory idFactory)

addOutputText

@NotNull
public static javax.faces.component.html.HtmlOutputText addOutputText(@NotNull
                                                                              javax.faces.component.UIComponent parent,
                                                                              FacesComponentIdFactory idFactory,
                                                                              CharSequence value,
                                                                              String styleClass)

createOutputText

@NotNull
public static javax.faces.component.html.HtmlOutputText createOutputText(FacesComponentIdFactory idFactory,
                                                                                 CharSequence value,
                                                                                 String styleClass)

addColumn

@NotNull
public static javax.faces.component.html.HtmlColumn addColumn(@NotNull
                                                                      javax.faces.component.UIComponent parent,
                                                                      FacesComponentIdFactory idFactory,
                                                                      CharSequence headerText,
                                                                      String headerStyle)

addVerbatimText

@NotNull
public static javax.faces.component.html.HtmlOutputText addVerbatimText(@NotNull
                                                                                javax.faces.component.UIComponent parent,
                                                                                CharSequence html)

addButton

@NotNull
public static javax.faces.component.UIOutput addButton(javax.faces.component.UIComponent parent,
                                                               String label,
                                                               String styleClass)

addJavaScript

@NotNull
public static javax.faces.component.UIOutput addJavaScript(@NotNull
                                                                   javax.faces.component.UIComponent parent,
                                                                   FacesComponentIdFactory idFactory,
                                                                   @Nullable
                                                                   CharSequence src,
                                                                   @Nullable
                                                                   CharSequence script)

getDescendantsOfType

@NotNull
public static <T extends javax.faces.component.UIComponent> List<T> getDescendantsOfType(javax.faces.component.UIComponent component,
                                                                                                 Class<T> componentClass)

getAncestorOfType

public static <T extends javax.faces.component.UIComponent> T getAncestorOfType(javax.faces.component.UIComponent component,
                                                                                Class<T> componentClass)

addLabel

@NotNull
public static javax.faces.component.html.HtmlOutputLabel addLabel(@NotNull
                                                                          javax.faces.component.UIComponent parent,
                                                                          FacesComponentIdFactory idFactory,
                                                                          javax.faces.component.UIInput associatedInput,
                                                                          String value,
                                                                          String styleClass)

addGraphicImage

@NotNull
public static javax.faces.component.html.HtmlGraphicImage addGraphicImage(@NotNull
                                                                                  javax.faces.component.UIComponent parent,
                                                                                  FacesComponentIdFactory idFactory,
                                                                                  String url,
                                                                                  String alt)

addOutputLink

@NotNull
public static javax.faces.component.html.HtmlOutputLink addOutputLink(@NotNull
                                                                              javax.faces.component.UIComponent parent,
                                                                              FacesComponentIdFactory idFactory,
                                                                              String value)

addParameter

@NotNull
public static javax.faces.component.UIParameter addParameter(@NotNull
                                                                     javax.faces.component.UIComponent parent,
                                                                     FacesComponentIdFactory idFactory,
                                                                     String name,
                                                                     String value)

addForm

@NotNull
public static javax.faces.component.html.HtmlForm addForm(@NotNull
                                                                  javax.faces.component.UIComponent parent,
                                                                  FacesComponentIdFactory idFactory)

addCommandButton

@NotNull
public static javax.faces.component.html.HtmlCommandButton addCommandButton(@NotNull
                                                                                    javax.faces.component.UIComponent parent,
                                                                                    FacesComponentIdFactory idFactory,
                                                                                    String value,
                                                                                    String styleClass)

addCommandLink

@NotNull
public static javax.faces.component.html.HtmlCommandLink addCommandLink(@NotNull
                                                                                javax.faces.component.UIComponent parent,
                                                                                FacesComponentIdFactory idFactory)

addMessage

@NotNull
public static javax.faces.component.html.HtmlMessage addMessage(@NotNull
                                                                        javax.faces.component.UIComponent parent,
                                                                        FacesComponentIdFactory idFactory,
                                                                        String associatedComponentId,
                                                                        String styleClass)

addPanelGrid

@NotNull
public static javax.faces.component.html.HtmlPanelGrid addPanelGrid(@NotNull
                                                                            javax.faces.component.UIComponent parent,
                                                                            FacesComponentIdFactory idFactory,
                                                                            int columns,
                                                                            String styleClass)

addDataTable

@NotNull
public static javax.faces.component.html.HtmlDataTable addDataTable(@NotNull
                                                                            javax.faces.component.UIComponent parent,
                                                                            FacesComponentIdFactory idFactory,
                                                                            String styleClass)

getExpressionAttribute

@Nullable
public static String getExpressionAttribute(@NotNull
                                                     javax.faces.component.UIComponent component,
                                                     @NotNull
                                                     String attribName)

getExpressionAttribute

@Nullable
public static <T> T getExpressionAttribute(@NotNull
                                                    javax.faces.component.UIComponent component,
                                                    @NotNull
                                                    String attribName,
                                                    @NotNull
                                                    Class<T> expectedType)

getParameters

@NotNull
public static Map<String,String> getParameters(@NotNull
                                                       javax.faces.component.UIComponent component)

createComponent

public static <T extends javax.faces.component.UIComponent> T createComponent(Class<T> componentClass)
Creates a UIComponent of the specified type.

Parameters:
componentClass - the type of UIComponent to create
Returns:
a UIComponent of the specified type

createComponent

public static <T extends javax.faces.component.UIComponent> T createComponent(Class<T> componentClass,
                                                                              @Nullable
                                                                              FacesComponentIdFactory idFactory)
Creates a UIComponent of the specified type.

Parameters:
componentClass - the type of UIComponent to create
idFactory - a factory to use to create a unique id for the new component
Returns:
a UIComponent of the specified type

setDisabled

public static void setDisabled(javax.faces.component.UIComponent component,
                               boolean disabled)
Sets the "disabled" attribute on the specified component to the provided value. NOTE: Not all components will render this attribute (e.g. HtmlInputHidden does not render it).

Parameters:
component - a component
disabled - the new value for the "disabled" attribute

isDisabled

public static boolean isDisabled(javax.faces.component.UIComponent component)
Gets the value of the "disabled" attribute on the specified component, or false if the component does not expose the attribute.

Parameters:
component - a component
Returns:
the value of the "disabled" attribute on the specified component, or false if the component does not expose the attribute

setReadonly

public static void setReadonly(javax.faces.component.UIInput input,
                               boolean readonly)
Sets the "readonly" attribute on the specified component to the provided value. NOTE: Only certain components will render this attribute (e.g. HtmlInputText, HtmlInputSecret, and HtmlInputTextarea render it).

Parameters:
input - an input component
readonly - the new value for the "readonly" attribute

isReadonly

public static boolean isReadonly(javax.faces.component.UIComponent component)
Gets the value of the "readonly" attribute on the specified component, or false if the component does not expose the attribute.

Parameters:
component - a component
Returns:
the value of the "readonly" attribute on the specified component, or false if the component does not expose the attribute

setUnset

public static void setUnset(javax.faces.component.UIInput input,
                            boolean unset)
Sets the "unset" attribute on the specified component to the provided value. NOTE: This is a RHQ-specific attribute, which is only rendered for the Config component.

Parameters:
input - an input component
unset - the new value for the "unset" attribute

isUnset

public static boolean isUnset(javax.faces.component.UIComponent component)
Gets the value of the "unset" attribute on the specified component, or false if the component does not expose the attribute.

Parameters:
component - a component
Returns:
the value of the "unset" attribute on the specified component, or false if the component does not expose the attribute

setOverride

public static void setOverride(javax.faces.component.UIInput input,
                               boolean override)

isOverride

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

detachComponent

public static void detachComponent(javax.faces.component.UIComponent component)
Removes the specified component from its parent if it has one.

Parameters:
component - a JSF component

getEnclosingForm

@Nullable
public static javax.faces.component.UIForm getEnclosingForm(javax.faces.component.UIComponent component)
                                                     throws IllegalArgumentException
Returns the enclosing UIForm component, if any, from the specified component's ancestry.

Parameters:
component - the component
Returns:
the enclosing UIForm component, if any, from the specified component's ancestry
Throws:
IllegalArgumentException - if more than one UIForm is found in the component's ancestry


Copyright © 2008-2012 Red Hat, Inc.. All Rights Reserved.