org.javalid.external.jsf
Class JvJsfContextListener

java.lang.Object
  extended by org.javalid.external.jsf.JvJsfContextListener
All Implemented Interfaces:
java.util.EventListener, javax.servlet.ServletContextListener

public class JvJsfContextListener
extends java.lang.Object
implements javax.servlet.ServletContextListener

Use this context listener to store both the AnnotationValidator and the JvJsfConfiguration instance in the servlet context. The UpdateValuesPhaseListener does depend on this (if you use it).

AnnotationValidator is stored under the key 'JsfFacadeShared.KEY_ANNOTATION_VALIDATOR_LOCATION'. JvJsfConfiguration is stored under JsfFacadeShared.KEY_JSF_CONFIGURATION_LOCATION.

The listener expects an init-parameter in the web.xml file named: 'jv-jsf-config-file' containing the full path of the xml configuration file for jsf support.

To load the annotation validator specify an xml file by init-parameter: 'jv-config-file', else a default AnnotationValidator config file is used.

Finally to use a different AnnotationValidator you can specify jv-validator-class in the web.xml as init-parameter telling what class to use. Note the validator must have at least 1 parameter representing the xmlConfigFile to use to load (java.lang.String). The optional second parameter is:
jv-value-to-null-if-empty: either true or false. If true, String / StringBuffer values being bound on an object, if they are empty "" (jsf mostly submits empty values of users as "" instead of null) are set to NULL during validation (not on the object itself) to prevent firing other validation annotations. This is relevant for non-required fields. By default the annotationvalidator sets this option to false (default framework behavior), override it here if needed (and you likely need it!).

Changes for 1.0.1:

Since:
1.0
Version:
1.0.1
Author:
M.Reuvers

Field Summary
static java.lang.String JV_ANNOTATION_VALIDATOR_CONFIG_FILE_INIT_PARAM
          Servlet init parameter name (web.xml), the value should tell what JV config file to use (full path).
static java.lang.String JV_ANNOTATION_VALIDATOR_IMPLEMENTATION_CLASS_INIT_PARAM
          Servlet init parameter name (web.xml), denoting which AnnotationValidator class must be instantiated (and stored in the servlet context).
static java.lang.String JV_JSF_CONFIG_FILE_INIT_PARAM
          Servlet init parameter name (web.xml), the value should tell what config file to use (full path).
static java.lang.String JV_VALUE_TO_NULL_FOR_EMPTY_STRING_INIT_PARAM
          Servlet init parameter name (web.xml), denoting whether to set empty string/stringbuffer values to null during validation.
 
Constructor Summary
JvJsfContextListener()
           
 
Method Summary
 void contextDestroyed(javax.servlet.ServletContextEvent event)
           
 void contextInitialized(javax.servlet.ServletContextEvent event)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

JV_JSF_CONFIG_FILE_INIT_PARAM

public static final java.lang.String JV_JSF_CONFIG_FILE_INIT_PARAM
Servlet init parameter name (web.xml), the value should tell what config file to use (full path). REQUIRED.

See Also:
Constant Field Values

JV_ANNOTATION_VALIDATOR_CONFIG_FILE_INIT_PARAM

public static final java.lang.String JV_ANNOTATION_VALIDATOR_CONFIG_FILE_INIT_PARAM
Servlet init parameter name (web.xml), the value should tell what JV config file to use (full path). OPTIONAL. If not specified falls back to the default JV config file.

See Also:
Constant Field Values

JV_ANNOTATION_VALIDATOR_IMPLEMENTATION_CLASS_INIT_PARAM

public static final java.lang.String JV_ANNOTATION_VALIDATOR_IMPLEMENTATION_CLASS_INIT_PARAM
Servlet init parameter name (web.xml), denoting which AnnotationValidator class must be instantiated (and stored in the servlet context). OPTIONAL. If not provided, loads default AnnotationValidationImpl class.

See Also:
Constant Field Values

JV_VALUE_TO_NULL_FOR_EMPTY_STRING_INIT_PARAM

public static final java.lang.String JV_VALUE_TO_NULL_FOR_EMPTY_STRING_INIT_PARAM
Servlet init parameter name (web.xml), denoting whether to set empty string/stringbuffer values to null during validation. See comment of this class for more info. OPTIONAL. If not provided, does not reset values to null if empty during validation. Value must be true / false.

See Also:
Constant Field Values
Constructor Detail

JvJsfContextListener

public JvJsfContextListener()
Method Detail

contextInitialized

public void contextInitialized(javax.servlet.ServletContextEvent event)
Specified by:
contextInitialized in interface javax.servlet.ServletContextListener

contextDestroyed

public void contextDestroyed(javax.servlet.ServletContextEvent event)
Specified by:
contextDestroyed in interface javax.servlet.ServletContextListener