org.javalid.external.jsf
Class JsfSupport

java.lang.Object
  extended by org.javalid.external.jsf.JsfSupport

public class JsfSupport
extends java.lang.Object

Utility class for JSF.

Changes for 1.0.1:

Since:
1.0
Version:
1.0.1
Author:
M.Reuvers

Field Summary
static java.lang.String KEY_ANNOTATION_VALIDATOR_LOCATION
          See JsfFacadeShared, this one is here for backwards compatibility only.
static java.lang.String KEY_JSF_CONFIGURATION_LOCATION
          See JsfFacadeShared, this one is here for backwards compatibility only.
 
Method Summary
static java.lang.String addJsfExpressionTag(java.lang.String value)
          This method adds an expression tag around given value, thus #{value}.
static javax.faces.application.FacesMessage createFacesMessage(java.util.ResourceBundle bundle, java.lang.String jvMessage, java.lang.Object[] paramValues, java.util.Locale locale)
          Creates a new faces message.
static javax.faces.application.FacesMessage createFacesMessage(java.util.ResourceBundle bundle, java.lang.String jvMessage, java.lang.Object[] paramValues, java.util.Locale locale, javax.faces.application.FacesMessage.Severity severity)
          Creates a new faces message.
static java.lang.ClassLoader getCurrentClassLoader()
          Returns the classloader to use, by default the current thread's classloader otherwise the one of this class.
static JsfFacade getJsfFacade()
          Returns the current loaded jsf facade that is used by this class.
static java.util.ResourceBundle getResourceBundle(java.util.Locale locale, java.lang.String bundleName)
          Returns the ResourceBundle, raises JvException if no ResourceBundle was found.
static java.util.ResourceBundle getResourceBundleFromJsfConfiguration(javax.faces.context.FacesContext context, java.util.Locale locale)
          Convenience method, which loads the resource bundle that was defined in the jv jsf configuration file.
static boolean isJsfExpression(java.lang.String value)
          Checks if given value starts with #{ or ${ and ends with }, like a jsf expression.
static AnnotationValidator locateAnnotationValidator(javax.faces.context.FacesContext context)
          Deprecated. Will be removed in the next major release, use JsfFacadeShared instead.
static JsfConfigurationDeclarative locateJsfConfiguration(javax.faces.context.FacesContext context)
          This method attempts to locate the JsfConfiguration, does NOT initiate one.
static java.lang.String stripJsfTagFromExpression(java.lang.String expression)
          Removes expression accolades from expression.
static boolean validateUsingJsfConfiguration(javax.faces.context.FacesContext ctx, AnnotationValidator validator, JsfConfigurationDeclarative jsfConfig, java.lang.String bundleName)
          Performs validation of a business object using given validator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

KEY_ANNOTATION_VALIDATOR_LOCATION

public static final java.lang.String KEY_ANNOTATION_VALIDATOR_LOCATION
See JsfFacadeShared, this one is here for backwards compatibility only.

See Also:
JsfFacadeShared, Constant Field Values

KEY_JSF_CONFIGURATION_LOCATION

public static final java.lang.String KEY_JSF_CONFIGURATION_LOCATION
See JsfFacadeShared, this one is here for backwards compatibility only.

See Also:
JsfFacadeShared, Constant Field Values
Method Detail

getResourceBundle

public static final java.util.ResourceBundle getResourceBundle(java.util.Locale locale,
                                                               java.lang.String bundleName)
Returns the ResourceBundle, raises JvException if no ResourceBundle was found.

Parameters:
locale - the Locale to get the bundle in
bundleName - Fully qualified bundlename (properties file)
Returns:
ResourceBundle

isJsfExpression

public static final boolean isJsfExpression(java.lang.String value)
Checks if given value starts with #{ or ${ and ends with }, like a jsf expression. For details see JsfFacadeShared, this one is here for backwards compatibility only.

Parameters:
value - The value to check
Returns:
True if it conforms a jsf expression, false otherwise.
See Also:
JsfFacadeShared.isExpression(java.lang.String)

stripJsfTagFromExpression

public static final java.lang.String stripJsfTagFromExpression(java.lang.String expression)
Removes expression accolades from expression. Check out JsfFacadeShared as the method there is actually used. This one is here for backwards compatibility only.

Parameters:
expression - The expression to strip off #{}
Returns:
The stripped expression, if expression was null, returns null as well.
See Also:
JsfFacadeShared.removeExpression(java.lang.String)

addJsfExpressionTag

public static final java.lang.String addJsfExpressionTag(java.lang.String value)
This method adds an expression tag around given value, thus #{value}. For details check out JsfFacadeShared. This one is here for backwards compatibility only.

Parameters:
value - The value to add an expression tag to
Returns:
Value with expression tag.
See Also:
JsfFacadeShared.addExpression(java.lang.String)

createFacesMessage

public static final javax.faces.application.FacesMessage createFacesMessage(java.util.ResourceBundle bundle,
                                                                            java.lang.String jvMessage,
                                                                            java.lang.Object[] paramValues,
                                                                            java.util.Locale locale)
Creates a new faces message.

Parameters:
bundle - The bundle to use to lookup jvMessage (that's a .properties code)
jvMessage - The message (code) to lookup in the bundle
paramValues - Values to format the message with (if any, can be null)
locale - The locale to use for the message formatter
Returns:
FacesMessage

createFacesMessage

public static final javax.faces.application.FacesMessage createFacesMessage(java.util.ResourceBundle bundle,
                                                                            java.lang.String jvMessage,
                                                                            java.lang.Object[] paramValues,
                                                                            java.util.Locale locale,
                                                                            javax.faces.application.FacesMessage.Severity severity)
Creates a new faces message.

Parameters:
bundle - The bundle to use to lookup jvMessage (that's a .properties code)
jvMessage - The message (code) to lookup in the bundle
paramValues - Values to format the message with (if any, can be null)
locale - The locale to use for the message formatter
severity - Set the severity of this message
Returns:
FacesMessage

validateUsingJsfConfiguration

public static final boolean validateUsingJsfConfiguration(javax.faces.context.FacesContext ctx,
                                                          AnnotationValidator validator,
                                                          JsfConfigurationDeclarative jsfConfig,
                                                          java.lang.String bundleName)
Performs validation of a business object using given validator.

Parameters:
ctx - The context to use
validator - The annotationvalidator to use here
jsfConfig - The configuration information about the jsf-support extension
bundleName - The bundleName to use (to get the messages from)
Returns:
True if validation errors were encountered (thus set to the faces context), false if everything was fine.

locateAnnotationValidator

public static final AnnotationValidator locateAnnotationValidator(javax.faces.context.FacesContext context)
Deprecated. Will be removed in the next major release, use JsfFacadeShared instead.

This method attempts to locate a AnnotationValidator, does NOT initiate one. Currently it checks if it is bound in the ServletContext. Use JsfFacadeShared one instead, this one will be removed!

Parameters:
context - The facescontext to check
Returns:
AnnotationValidator instance that is bound somewhere (thru configuration).
Throws:
JavalidException - if the validator could not be found
See Also:
JsfFacadeShared.findAnnotationValidator(javax.faces.context.FacesContext)

locateJsfConfiguration

public static final JsfConfigurationDeclarative locateJsfConfiguration(javax.faces.context.FacesContext context)
This method attempts to locate the JsfConfiguration, does NOT initiate one. Currently it checks if it is bound to the ServletContext

Parameters:
context - The facescontext to check
Returns:
JsfConfiguration instance that is bound somewhere (thru configuration)
Throws:
JavalidException - if the JsfConfiguration could not be found

getResourceBundleFromJsfConfiguration

public static final java.util.ResourceBundle getResourceBundleFromJsfConfiguration(javax.faces.context.FacesContext context,
                                                                                   java.util.Locale locale)
Convenience method, which loads the resource bundle that was defined in the jv jsf configuration file. If not defined there, uses the default faces bundle. If none was found raises an exception.

Parameters:
context - The context to use
locale - The locale to get the bundle in
Returns:
ResourceBundle found
Throws:
JavalidException - Raised if the bundle was not found

getCurrentClassLoader

public static final java.lang.ClassLoader getCurrentClassLoader()
Returns the classloader to use, by default the current thread's classloader otherwise the one of this class.

Returns:
ClassLoader to use

getJsfFacade

public static final JsfFacade getJsfFacade()
Returns the current loaded jsf facade that is used by this class.

Returns:
Current JsfFacade (or null if JsfSupport failed to load it!).
Since:
1.0.1