|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectorg.javalid.external.jsf.JsfMessageConverter
public class JsfMessageConverter
This class can be used to convert a standard List<ValidationMessage> result to JSF (Java Server Faces) messages. Note that when you use this class, JSF libraries must be present as dependencies.
Changes for 1.0.1:
| Method Summary | |
|---|---|
static void |
convertMessages(java.util.List<ValidationMessage> messages,
javax.faces.context.FacesContext context)
The most simplistic way to convert Jv validation messages to JSF messages. |
static void |
convertMessages(java.util.List<ValidationMessage> messages,
javax.faces.context.FacesContext context,
java.lang.String bundleName)
The most simplistic way to convert Jv validation messages to JSF messages. |
static void |
convertMessages(java.util.List<ValidationMessage> messages,
javax.faces.context.FacesContext context,
java.lang.String parentViewId,
boolean ignoreComponentNotFound,
java.lang.String backingBeanName)
Converts given validation messages to JSF messages. |
static void |
convertMessages(java.util.List<ValidationMessage> messages,
javax.faces.context.FacesContext context,
java.lang.String parentViewId,
boolean ignoreComponentNotFound,
java.lang.String backingBeanName,
java.lang.String bundleName)
Converts given validation messages to JSF messages. |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Method Detail |
|---|
public static final void convertMessages(java.util.List<ValidationMessage> messages,
javax.faces.context.FacesContext context)
messages - The validation messages to convertcontext - The context to add the converted messages to
public static final void convertMessages(java.util.List<ValidationMessage> messages,
javax.faces.context.FacesContext context,
java.lang.String bundleName)
Convenience method
It does *not* take into account anything from the JSF environment, thus does not use any client-id's for the messages. Its best used for global type of messages. One pro though, it is fast.
messages - The validation messages to convertcontext - The context to add the converted messages tobundleName - The fully qualified name of a property file (without .properties), is used for lookup of messages
public static final void convertMessages(java.util.List<ValidationMessage> messages,
javax.faces.context.FacesContext context,
java.lang.String parentViewId,
boolean ignoreComponentNotFound,
java.lang.String backingBeanName)
Convenience method
For docs check the other method with same parameters + bundleName. Use this method if this method must use the bundlename directly from the facesContext, the bundlename that is defined in your faces-config.xml
convertMessages(List, FacesContext, String, boolean, String, String)
public static final void convertMessages(java.util.List<ValidationMessage> messages,
javax.faces.context.FacesContext context,
java.lang.String parentViewId,
boolean ignoreComponentNotFound,
java.lang.String backingBeanName,
java.lang.String bundleName)
One exception to this rule, if ValidationMessage.isGlobalMessage() returns true it is immediately added as a global message, this could be the case if the user set a validation annotation's globalMessage to true (in all annotations that ship with the framework the default is false).
As your components in JSF pages bind to a backing bean for their values to store, it is recommended to specify the bean name, which makes matching faster and most of all: accurate. If not provided the matching is on a per 'guessing' base, which may be incorrect if you have for instance two backing beans used in the same JSF page like: beanName1, beanName2 and both have a property 'name' (to store something in). Without a beanName given the first match is the first component encountered in the JSF page using one of these beans. If you use just one backing bean in your JSF, this problem won't occur.
messages - The validation messages to convertcontext - The context to use (and store messages to)parentViewId - The id of a JSF component which contains the EditableValueHolder components to match a message against
(all children, grandchildren etc. are searched for, so it is recommended to specify one which is close to
these components, so no f:view for instance, which would be expensive!). The component itself is not
used it self to match against. This id must be present.ignoreComponentNotFound - If set to true, if for a validation path no component was found a JSF message without client id is added. If
set to false an JvException is raised telling which component could not be found.backingBeanName - The backingBeanName to use as a prefix, if you use multiple backingBeans in your
page you can specify multiple names by separating them by a , . If left null, matching is done
on a guessing base.bundleName - The bundleName to use (to load a resource file to get the messages from)
JavalidException - Raised if the parentViewId cannot be found or if ignoreComponentNotFound=false and a component
could not be found for a message, a resource bundle is not present etc.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||