validation in JSF

Hi All,

Can anybody please help me on this.

Since many days I am not able to figure out the problem.

My scenorio is,

I want to do validation like.

I have 2 text boxes one for first name & other for last name.If user doesn't enter anything in text boxes it should display messege as,

First Name is required.

Last Name is required.

But I am only able to see messge asValue is required.

<h:inputText id="firstName" value="#{Bean.FirstName}" required="true"/>

<h:inputText id="lastName" value="#{Bean.lastName}"

required="true"/>

I am using jsf-api.jar,jsf-impl.jar,myfaces-api.jar,myfaces-impl.jar,tomahawk.jar.

So is it library related issue or there is another way to display messege as above?

Sandip Patil

[829 byte] By [sandip_03_jsfa] at [2007-11-26 16:32:03]
# 1

Page

<h:inputText id="firstName" value="# Bean.FirstName}"required="true"/>

<h:message for="firstName"/>

in your faces config xml file you have to put something like this

<application>

<message-bundle>

webadmin.MyErrors <-this is the path to the .properties file that is defined below

</message-bundle>

</application>

in in your project you create a file called "whatever" (in this case MyErrors.properties) In that file have this:

javax.faces.component.UIInput.REQUIRED=First Name must be filled in.

null

Hope that helps

jbayuga

P.S. I have no idea how to get it to distinguish first and last name. I just make a generic message like " Name field is required"

jbayugaa at 2007-7-8 22:56:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

Hi jbayuga,

Thanks a lot for your reply.

But the same problem I am facing how to differentiate if I do not want to give general messege as Please fill all Values.

I want two seperate messeges as Please enter first name,Please enter last name if user doesnt enter anything in both text boxes.

Thnaks

Sandip

sandip_03_jsfa at 2007-7-8 22:56:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Upgrade to JSF 1.2 and use the requiredMessage attribute.
BalusCa at 2007-7-8 22:56:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 4
try This !! http://www.velocityreviews.com/forums/t141766-form-validation-in-jsf.html
lava at 2007-7-8 22:56:39 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...