Package de.xima.fc.gui.util
Class FacesHelper
- java.lang.Object
-
- de.xima.fc.gui.util.FacesHelper
-
public class FacesHelper extends Object
-
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static String
createDynamicResourceUrl(javax.faces.context.FacesContext context, String expression, Map<String,String> params, boolean cache)
static <T> T
getBeanCreateIfMissing(Class<T> beanClass, Annotation... qualifiers)
Deprecated.static String
getBeanName(Class<?> beanClass, Annotation... qualifiers)
Deprecated.static <T> T
getBeanNullIfMissing(Class<T> beanClass, Annotation... qualifiers)
Deprecated.static Set<javax.faces.component.UIForm>
getCurrentForms(javax.faces.context.FacesContext context)
Similar toComponents.getCurrentForm()
, but finds all forms.static Locale
getLocaleOrDefault()
static void
hideDialogByWidgetVar(String widgetVar)
static javax.faces.application.FacesMessage.Severity
maxSeverity(javax.faces.application.FacesMessage.Severity lhs, javax.faces.application.FacesMessage.Severity rhs)
static void
showDialogByWidgetVar(String widgetVar)
-
-
-
Method Detail
-
createDynamicResourceUrl
public static String createDynamicResourceUrl(javax.faces.context.FacesContext context, String expression, Map<String,String> params, boolean cache)
- Parameters:
context
- Current faces context.expression
- Expression to invoke when the resource needs to be fetched, e.g. a bean method. It must return aStreamedContent
.params
- URL parameters to include in the resource URL.cache
- Whether the resource can be cached.- Returns:
- The URL for a dynamic resource that retrieves data from the given expression (e.g. a bean method).
-
getLocaleOrDefault
public static Locale getLocaleOrDefault()
- Returns:
- The locale from the current Faces context, or the default locale when there is no active Faces context or it does not have a locale set.
-
getBeanCreateIfMissing
@Deprecated public static <T> T getBeanCreateIfMissing(Class<T> beanClass, Annotation... qualifiers)
Deprecated.Returns the JSF bean (request scoped, view scoped, session scoped, conversation scoped, or application scoped) of the given class. When the bean was not created yet, creates the bean.- Type Parameters:
T
- Type of the bean to lookup.- Parameters:
beanClass
- Class of the bean to lookup.qualifiers
- Optional qualifiers for the bean.- Returns:
- The bean instance of the given class.
-
getBeanName
@Deprecated public static String getBeanName(Class<?> beanClass, Annotation... qualifiers)
Deprecated.- Parameters:
beanClass
- Class of the bean to lookup.qualifiers
- Optional qualifiers for the bean.- Returns:
- The name of the JSF bean (request scoped, view scoped, session scoped, conversation scoped, or application scoped).
-
getBeanNullIfMissing
@Nullable @Deprecated public static <T> T getBeanNullIfMissing(Class<T> beanClass, Annotation... qualifiers)
Deprecated.Checks if an instance of the JSF bean (request scoped, view scoped, session scoped, conversation scoped, or application scoped) exists, and returns the bean if it does. When the bean was not created yet, returnsnull
.- Type Parameters:
T
- Type of the bean to lookup.- Parameters:
beanClass
- Class of the bean to lookup.qualifiers
- Optional qualifiers for the bean.- Returns:
- The bean instance if the bean was created already, or
null
otherwise.
-
maxSeverity
public static javax.faces.application.FacesMessage.Severity maxSeverity(javax.faces.application.FacesMessage.Severity lhs, javax.faces.application.FacesMessage.Severity rhs)
- Parameters:
lhs
- First severity to process.rhs
- Second severity to process.- Returns:
- The severity with the higher level. The order is
fatal
,error
,warn
,info
, from highest to lowest.
-
showDialogByWidgetVar
public static void showDialogByWidgetVar(String widgetVar)
-
hideDialogByWidgetVar
public static void hideDialogByWidgetVar(String widgetVar)
-
getCurrentForms
public static Set<javax.faces.component.UIForm> getCurrentForms(javax.faces.context.FacesContext context)
Similar toComponents.getCurrentForm()
, but finds all forms. Strictly speaking, JSF only allows one form to beexecute
d during postback. For non-AJAX requests, only one form is possible. But for AJAX requests, PrimeFaces supports components from different forms to beexecute
d (process
ed).Returns the currently submitted UI form components, or
empty set
if there is none, which may happen when the current request is not a postback request at all, or when the view has been changed by for example a successful navigation. If the latter is the case, you'd better invoke this method before navigation.- Parameters:
context
- Current faces context.- Returns:
- The currently submitted UI form components.
-
-