myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jesus Jr M Salvo <>
Subject Extval: Getting a simple @RequiredIf working in JSF2
Date Tue, 13 Nov 2012 09:17:49 GMT

As can be seen from the subject, I haven't used Extval before, and I
am having trouble testing out a simple proof-of-concept for
cross-validation in a JSF2 application.

My environment is as follows:

1) JBoss 7.1.1 ( NOT using MyFaces Core, but using the built-in
Mojarra JSF implementation )
2) Extval JARs in WEB-INF/lib:


I did not include myfaces-extval-generic-support-2.0.5.jar as I get a

   Caused by: java.lang.ClassNotFoundException:

I could not find what version of cglib and asm is required, so I
downloaded the latest versions of cglib and asm from the corresponding
websites and added them to WEB-INF/lib. But then, I get:

   java.lang.VerifyError: class net.sf.cglib.core.DebuggingClassWriter
overrides final method visit
   Critical error during deployment: : java.lang.NoClassDefFoundError:

So therefore removed myfaces-extval-generic-support-2.0.5.jar. It
seems that I don't really need it anyway. After removing
generic-support, JBoss startsup.

But anyway, back to the original question, I need to conditionally
validate that a property is required only when another property is set
to a specific value. So, I have the following bean:

	package test;


	import javax.faces.bean.ManagedBean;
	import javax.faces.bean.ViewScoped;

	import org.apache.myfaces.extensions.validator.crossval.annotation.RequiredIf;

	public class ViewBean implements Serializable {

		private static final long serialVersionUID = 1L;

		private String type;
		@RequiredIf(valueOf="#{type eq 'OPT2'}")
		private String text;

		public String getType() {
			return type;

		public String getText() {
			return text;

		public void setType(String type) {
			this.type = type;

		public void setText(String text) {
			this.text = text;


In the bean above, I only want to indicate that the property "text" is
required only if the property type is "OPT2". The sample XHTML file
below shows a fixed list of f:selectItems, one of which has a
itemValue of "OPT2", which I am expecting that, if I select the option
of "OPT2" ( with label of "Option 2" ), and I leave the text field
blank ( thereby leaving the "text" property of the bean empty, I am
expecting an output from h:messages.

	<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
	<html xmlns=""

	        Type:<h:selectOneMenu id="f_clmTyp" value="#{viewBean.type}"
	            required="true" requiredMessage="Claim Type is required">
	            <f:selectItem itemLabel="Option 1" itemValue="OPT1"/>
	            <f:selectItem itemLabel="Option 2" itemValue="OPT2"/>
	            <f:selectItem itemLabel="Option 3" itemValue="OPT3"/>
	        <h:inputText id="f_text" value="#{viewBean.text}"/>
	        <h:commandButton name="Submit" value="Submit"/>
	Submitted type: <h:outputText value="#{viewBean.type}"/><br/>
	Submitted text: <h:outputText value="#{viewBean.text}"/>

In WEB-INF/web.xml, I have:


But when I submit the form, I do not get any validation messages
outputted by h:messages.
I must be missing something simple, but what is it ??

Note: I have also tried setting
with the same result. In any case, in the long run, I have to rely on
setting it to false because of existing bugs in both Mojarra and
MyFaces core implementations ( actually, in the JSF specs themslves )
with regards to this context parameter:

Also, another question is .. and maybe answers my original question
above.. how does Extval perform cross-validation on the bean
properties when according to the JSF lifecycle, the bean properties
are updated ( UPDATE_MODEL_VALUES ) AFTER the validation phase (



View raw message