|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.javalid.external.jsf.JvJsfContextListener
public class JvJsfContextListener
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 (if and only if you don't use the useBean option).
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 there are two ways:
1) 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 latter
is an old feature (and may be removed in the future), you'd best off to use the @NotEmpty annotation on your model objects instead of @NotNull.
This is relevant for non-required fields. By default the annotationvalidator sets this option to false (default
framework behavior), override it here if needed.
2) Specify the jv-use-bean init parameter in web.xml, and set it to true. By doing so you must also specify the jv-bean-name parameter to tell what bean to use defined in either Spring or JSF e.g. myValidator (if the bean is called that way). The framework will first attempt to find it in Spring (if you have that on your classpath) and if that isnt there (or fails) attempts to find it using the JSF EL resolver.
Changes for 1.0.1:
| Field Summary | |
|---|---|
static java.lang.String |
JV_ANNOTATION_USE_BEAN_INIT_PARAM
Servlet init parameter name (web.xml), denoting if a Spring bean must be specified or the normal jv-validator-class. |
static java.lang.String |
JV_ANNOTATION_VALIDATOR_BEAN_CLASS_INIT_PARAM
Servlet init parameter name (web.xml), denoting which bean must be found (in Spring WebApplicationContext or JSF EL context, both are tried in that order if available). |
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 |
|---|
public static final java.lang.String JV_JSF_CONFIG_FILE_INIT_PARAM
public static final java.lang.String JV_ANNOTATION_VALIDATOR_CONFIG_FILE_INIT_PARAM
public static final java.lang.String JV_ANNOTATION_VALIDATOR_IMPLEMENTATION_CLASS_INIT_PARAM
public static final java.lang.String JV_ANNOTATION_VALIDATOR_BEAN_CLASS_INIT_PARAM
public static final java.lang.String JV_ANNOTATION_USE_BEAN_INIT_PARAM
public static final java.lang.String JV_VALUE_TO_NULL_FOR_EMPTY_STRING_INIT_PARAM
| Constructor Detail |
|---|
public JvJsfContextListener()
| Method Detail |
|---|
public void contextInitialized(javax.servlet.ServletContextEvent event)
contextInitialized in interface javax.servlet.ServletContextListenerpublic void contextDestroyed(javax.servlet.ServletContextEvent event)
contextDestroyed in interface javax.servlet.ServletContextListener
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||