- java.lang.Object
-
- org.omnifaces.util.ComponentsLocal
-
public final class ComponentsLocal extends Object
Collection of utility methods for the Faces API with respect to working with
UIComponent
. There are several traversal/lookup methods, there are severalUIForm
andUIInput
related methods which makes it easier to deal with forms and inputs.The difference with
Components
is that no one method ofComponentsLocal
obtains theFacesContext
from the current thread byFacesContext.getCurrentInstance()
. This job is up to the caller. This is more efficient in situations where multiple utility methods needs to be called at the same time. InvokingFacesContext.getCurrentInstance()
is at its own an extremely cheap operation, however as it's to be obtained as aThreadLocal
variable, it's during the call still blocking all other running threads for some nanoseconds or so.- Since:
- 4.6
- Author:
- Bauke Scholtz
- See Also:
Components
-
-
Method Summary
-
-
-
Method Detail
-
getCurrentComponent
public static <C extends UIComponent> C getCurrentComponent(FacesContext context)
- See Also:
Components.getCurrentComponent()
-
findComponent
public static <C extends UIComponent> C findComponent(FacesContext context, String clientId)
- See Also:
Components.findComponent(String)
-
findComponentRelatively
public static <C extends UIComponent> C findComponentRelatively(FacesContext context, UIComponent component, String clientId)
-
findComponentInParents
public static <C extends UIComponent> C findComponentInParents(FacesContext context, UIComponent component, String clientId)
-
findComponentInChildren
public static <C extends UIComponent> C findComponentInChildren(FacesContext context, UIComponent component, String clientId)
-
findComponentsInCurrentForm
public static <C extends UIComponent> List<C> findComponentsInCurrentForm(FacesContext context, Class<C> type)
-
forEachComponent
public static Components.ForEach forEachComponent(FacesContext context)
- See Also:
Components.forEachComponent()
-
createComponent
public static <C extends UIComponent> C createComponent(FacesContext context, String componentType)
- See Also:
Components.createComponent(String)
-
includeFacelet
public static void includeFacelet(FacesContext context, UIComponent parent, String path) throws IOException
- Throws:
IOException
- See Also:
Components.includeFacelet(UIComponent, String)
-
includeCompositeComponent
public static UIComponent includeCompositeComponent(FacesContext context, UIComponent parent, String libraryName, String tagName, String id)
-
includeCompositeComponent
public static UIComponent includeCompositeComponent(FacesContext context, UIComponent parent, String libraryName, String tagName, String id, Map<String,String> attributes)
-
addScript
public static void addScript(FacesContext context, String script)
- See Also:
Components.addScript(String)
-
addScriptResource
public static void addScriptResource(FacesContext context, String libraryName, String resourceName)
-
addFacesScriptResource
public static void addFacesScriptResource(FacesContext context)
- See Also:
Components.addFacesScriptResource()
-
buildView
public static UIViewRoot buildView(FacesContext context, String viewId) throws IOException
- Throws:
IOException
- See Also:
Components.buildView(String)
-
encodeHtml
public static String encodeHtml(FacesContext context, UIComponent component)
- See Also:
Components.encodeHtml(UIComponent)
-
getCurrentForm
public static UIForm getCurrentForm(FacesContext context)
- See Also:
Components.getCurrentForm()
-
getCurrentCommand
public static UICommand getCurrentCommand(FacesContext context)
- See Also:
Components.getCurrentCommand()
-
getCurrentActionSource
public static <C extends UIComponent> C getCurrentActionSource(FacesContext context)
- See Also:
Components.getCurrentActionSource()
-
getLabel
public static String getLabel(FacesContext context, UIComponent component)
- See Also:
Components.getLabel(UIComponent)
-
getOptionalLabel
public static String getOptionalLabel(FacesContext context, UIComponent component)
- See Also:
Components.getOptionalLabel(UIComponent)
-
getImmediateValue
public static <T> T getImmediateValue(FacesContext context, UIInput input)
- See Also:
Components.getImmediateValue(UIInput)
-
getExpectedValueType
public static <T> Class<T> getExpectedValueType(FacesContext context, UIComponent component)
-
getExpectedType
public static <T> Class<T> getExpectedType(FacesContext context, ValueExpression valueExpression)
-
hasInvokedSubmit
public static boolean hasInvokedSubmit(FacesContext context, UIComponent component)
- See Also:
Components.hasInvokedSubmit(UIComponent)
-
getParams
public static Map<String,List<String>> getParams(FacesContext context, UIComponent component, boolean includeRequestParams, boolean includeViewParams)
-
getMessageComponent
public static UIMessage getMessageComponent(FacesContext context, UIInput input)
- See Also:
Components.getMessageComponent(UIInput)
-
getMessagesComponent
public static UIMessages getMessagesComponent(FacesContext context)
- See Also:
Components.getMessagesComponent()
-
resetForm
public static void resetForm(FacesContext context, UIComponent component)
- See Also:
Components.resetForm(UIComponent)
-
resetInputs
public static void resetInputs(FacesContext context, UIComponent component)
- See Also:
Components.resetInputs(UIComponent)
-
disableInput
public static void disableInput(FacesContext context, String clientId)
- See Also:
Components.disableInput(String)
-
addFormIfNecessary
public static void addFormIfNecessary(FacesContext context)
- See Also:
Components.addFormIfNecessary()
-
convertToString
public static <T> String convertToString(FacesContext context, ValueHolder holder, T value)
-
getRenderedValue
public static String getRenderedValue(FacesContext context, ValueHolder holder)
-
invalidateInputs
public static void invalidateInputs(FacesContext context, String... relativeClientIds)
- See Also:
Components.invalidateInputs(String...)
-
invalidateInput
public static void invalidateInput(FacesContext context, String relativeClientId, String message, Object... params)
-
createValueExpression
public static ValueExpression createValueExpression(FacesContext context, String expression, Class<?> type)
-
createMethodExpression
public static MethodExpression createMethodExpression(FacesContext context, String expression, Class<?> returnType, Class<?>... parameterTypes)
-
createVoidMethodExpression
public static MethodExpression createVoidMethodExpression(FacesContext context, String expression, Class<?>... parameterTypes)
-
createActionListenerMethodExpression
public static MethodExpressionActionListener createActionListenerMethodExpression(FacesContext context, String expression)
-
createAjaxBehavior
public static AjaxBehavior createAjaxBehavior(FacesContext context, String expression)
- See Also:
Components.createAjaxBehavior(String)
-
getActionExpressionsAndListeners
public static List<String> getActionExpressionsAndListeners(FacesContext context, UIComponent component)
-
validateHasParent
public static <C extends UIComponent> void validateHasParent(FacesContext context, UIComponent component, Class<C> parentType)
-
validateHasDirectParent
public static <C extends UIComponent> void validateHasDirectParent(FacesContext context, UIComponent component, Class<C> parentType)
-
validateHasNoParent
public static <C extends UIComponent> void validateHasNoParent(FacesContext context, UIComponent component, Class<C> parentType)
-
validateHasChild
public static <C extends UIComponent> void validateHasChild(FacesContext context, UIComponent component, Class<C> childType)
-
validateHasOnlyChildren
public static <C extends UIComponent> void validateHasOnlyChildren(FacesContext context, UIComponent component, Class<C> childType)
-
validateHasNoChildren
public static void validateHasNoChildren(FacesContext context, UIComponent component)
-
-