wood burning stoves 2.0
The moose likes JSF and the fly likes JSF prevents custom validator from getting control Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF prevents custom validator from getting control " Watch "JSF prevents custom validator from getting control " New topic

JSF prevents custom validator from getting control

Gloria Green

Joined: Feb 19, 2008
Posts: 1

I am writing my first JSF application.

I have a jsp that contains a selectOneMenu that looks like this:

<h:selectOneMenu styleClass="selectOneMenu" id="priorityMenu"
<f:validator validatorId="RequestCodeValidator"></f:validator>
<f:selectItem itemValue="0" itemLabel="0" />
<f:selectItem itemValue="1" itemLabel="1" />
<f:selectItem itemValue="2" itemLabel="2" />

The command button looks like this:

<hx:commandExButton type="submit" value="Process All" styleClass="submitbutton"

My customers will use this application to build and change data. My inProgressRequestCode is a Request Code Unit class in my bean.

private RequestCodeUnit inProgressRequestCode;

The class contains variables for the data elements that make up a request code, such as priority number. We store each request code as a row in DB2.

I have a validator class, RequestCodeValidator, that I registered in faces-config.xml.

Here is my problem:

When we wish to change data for a request code, I read the appropriate row from DB2 and populate the variable fields in inProgressRequestCode. If requestCodeBean.inProgressRequestCode.priorityNumber contains one of the values listed in the selectOneMenu, all is well. My validator is invoked successfully. Unfortunately, we may have bad data in DB2. For example, if requestCodeBean.inProgressRequestCode.priorityNumber contains �3�, JSF writes a message like this to the console and prevents my validator from getting control:

[4/16/08 15:34:15:309 CDT] 00000027 jsf E com.sun.faces.context.FacesContextImpl addMessage Adding Message[sourceId=form1: priorityMenu,summary=Validation Error: Value is not valid)

JSF throws the �Validation Error: Value is not valid� message into a message in the jsp:

<h:messages styleClass="messages" id="errorMessages"
style="color: red">

It is not a terribly useful message for my customers, which is why I wrote the validator. How can I stop JSF from performing this validation, so my validator class can take care of it?

Thank you
I agree. Here's the link: http://aspose.com/file-tools
subject: JSF prevents custom validator from getting control
It's not a secret anymore!