WEBVTT

00:01.150 --> 00:03.100
Hello and welcome back.

00:03.130 --> 00:08.680
In this video, I'm going to give you an overview of validating JSP forms.

00:11.140 --> 00:13.240
We'll cover the following topics.

00:13.240 --> 00:13.580
Well.

00:13.600 --> 00:16.090
First, discuss the need for validation.

00:16.720 --> 00:21.040
Then we'll look at the built in features of validation in JSF.

00:22.090 --> 00:27.700
And then we'll take care of some housekeeping as far as creating a new Eclipse project for our validation

00:27.700 --> 00:28.270
demo.

00:31.910 --> 00:39.320
Now whenever you create an HTML form or a JSF form for that matter, you need to check the user input.

00:39.320 --> 00:43.850
So when entering the data, you may have certain fields in your form that are required.

00:43.880 --> 00:49.490
You also may have to validate the length of a field, say, for example, the number of digits in a

00:49.490 --> 00:56.510
postal code, or validate the numbers and a range like you'll only accept the numbers of 1 to 50.

00:56.840 --> 01:01.310
You may have to validate the format of data, like make sure it's a valid email address.

01:01.550 --> 01:07.220
Finally, you may have your own custom business rule that you need to apply for validation.

01:12.040 --> 01:19.360
Now the nice thing to know is that out of the box JSF has built in features for validation rules, so

01:19.360 --> 01:24.180
everything that I discussed on the previous slide JSF has built in support.

01:24.190 --> 01:28.000
So with JSF, you can check to make sure a field is required.

01:28.150 --> 01:30.550
You can validate the length of a field.

01:30.550 --> 01:34.690
You can also validate if it's a number or long in a given range.

01:35.350 --> 01:39.370
You can also validate formatting by using regular expressions.

01:39.370 --> 01:43.690
And finally there support for adding your own custom validation rule.

01:43.690 --> 01:46.990
So all of these features are available in JSF.

01:52.190 --> 01:54.050
Now let's discuss our road map.

01:54.050 --> 02:00.410
So there's a lot of features for validation with JSF, and if I covered everything, it would take forever.

02:00.410 --> 02:03.010
So I'm going to break it up into smaller videos.

02:03.020 --> 02:08.570
I'll have one video and check in the required fields, the next one on validating length as far as the

02:08.570 --> 02:09.410
range.

02:09.710 --> 02:16.580
And then I'll cover how to validate using the regular expressions or reg x and then we'll wrap it up

02:16.580 --> 02:17.420
with an example.

02:17.420 --> 02:19.460
On doing custom validation.

02:20.600 --> 02:27.200
So we'll break this up over multiple videos just so we have it available in nice bite sized chunks.

02:31.780 --> 02:32.230
All right.

02:32.230 --> 02:36.850
So let's go ahead and take care of some general housekeeping and the previous videos we may use of the

02:36.850 --> 02:38.200
Hello World example.

02:38.200 --> 02:43.540
And what I'd like to do instead here is create a new project that we can use for validation, and we'll

02:43.540 --> 02:46.270
use it in all the all of the following videos.

02:46.270 --> 02:50.230
So I'll actually show you how to create a new project for Validate demo.

02:53.290 --> 02:53.710
All right.

02:53.710 --> 02:55.930
So let's go ahead and move into Eclipse.

02:57.030 --> 02:59.520
And what I like to do is create a new project.

03:00.220 --> 03:01.750
So I'll go to file.

03:01.750 --> 03:04.660
I'll say new dynamic web project.

03:09.000 --> 03:12.510
And I'll create this new project named Validate Demo.

03:19.510 --> 03:22.270
And then I'll move down and I'll set up the configuration here.

03:22.270 --> 03:25.510
I'll click the modify button to modify the configuration.

03:25.510 --> 03:27.610
I want to make sure I have support for JSF.

03:27.610 --> 03:32.560
So over on the left hand side, make sure you check the box there right next to Java server faces.

03:33.950 --> 03:37.040
I mean, you can go ahead and hit the okay button in the bottom right corner.

03:41.620 --> 03:46.080
Now in this screen regarding our source folders, let's go ahead and make a modification here.

03:46.090 --> 03:50.620
Let's go ahead and select the first item source main Java and let's remove this entry.

03:51.880 --> 03:56.980
And now let's go ahead and click on Add folder and then we'll add the folder named Source.

03:57.160 --> 04:01.450
I'm making this change here just to stay consistent with our existing videos.

04:04.880 --> 04:05.240
All righty.

04:05.240 --> 04:06.110
So that looks pretty good.

04:06.110 --> 04:07.820
Let's go ahead and click on next.

04:12.310 --> 04:17.110
And then for the content directory, I'll change that directory name to web content.

04:17.110 --> 04:23.050
So again, staying consistent with our videos and also this is the directory name that was used in previous

04:23.050 --> 04:24.100
versions of Eclipse.

04:24.100 --> 04:28.180
So again, just staying consistent with what you'll see on Web projects.

04:31.610 --> 04:31.940
All righty.

04:31.940 --> 04:32.810
So that looks pretty good.

04:32.810 --> 04:34.520
Let's go ahead and click on next.

04:37.890 --> 04:43.110
Now for this section here for the JSF implementation library for the type, I'll choose the dropdown

04:43.110 --> 04:49.140
and I'll choose disable library configuration because we'll do this manually later in the video.

04:50.580 --> 04:54.030
I keep all the other defaults here for configuring the JSF servlet.

04:55.200 --> 04:56.250
And down near the bottom.

04:56.250 --> 05:03.300
This will allow us to access the JSF faces servlet by using interfaces prefix on our URL.

05:06.050 --> 05:07.700
I'll go ahead and click on Finish.

05:09.520 --> 05:15.040
And this will create a validate demo project for us that has support for JSF built in.

05:15.400 --> 05:17.770
So right now our source directory is empty.

05:17.980 --> 05:21.130
Our web content directory is empty except for our basic folders.

05:21.130 --> 05:24.040
But now we have our very basic project in place.

05:24.040 --> 05:28.570
And what we're going to do is we're going to make use of this validate demo project and all of the following

05:28.570 --> 05:32.830
videos where we'll walk through examples of all the various validation roles.

05:35.980 --> 05:38.660
Now there's still some additional steps that I need to do here.

05:38.680 --> 05:43.990
I actually need to download the JSF libraries and add them to my project, and I'll show you how to

05:43.990 --> 05:45.280
do that in a second.

05:46.890 --> 05:52.060
So let's go ahead and open up a web browser and we're going to download those JSF jar files.

05:52.080 --> 05:58.020
I'll simply go to love to code slash download JSF.

05:58.050 --> 06:04.170
This will actually redirect you to the repository where you can download the JSF libraries.

06:07.190 --> 06:07.550
All righty.

06:07.550 --> 06:11.060
So we're here at the repository here for JSF.

06:11.300 --> 06:16.480
Let's go ahead and scroll down on this list and I'll show you the actual file that you want to download.

06:16.490 --> 06:19.070
So let me go ahead and zoom in here for a second.

06:19.070 --> 06:25.780
You want to download the file Java X dot faces dash 2.2.8. jar.

06:25.790 --> 06:31.040
That's the version of the Jar file that will work with this video series with no problems.

06:33.680 --> 06:36.950
So you go and select that link, download it to your file system.

06:36.950 --> 06:39.920
Your browser may prompt you and then you have the file.

06:39.920 --> 06:41.810
Download it to your computer.

06:45.320 --> 06:49.040
All right, so let's go to our file system in my downloads directory.

06:49.070 --> 06:51.500
Here's the jar file that was just downloaded.

06:56.460 --> 07:00.400
So let's go ahead and get this set up for our Eclipse project.

07:00.420 --> 07:03.980
So we basically want to copy this to our Web live directory.

07:03.990 --> 07:08.130
So I'll go ahead and copy that jar file from my file system.

07:08.220 --> 07:13.890
I'll move over to Eclipse and I'll paste it into the directory web, EMF lib.

07:15.410 --> 07:19.820
It's very important that you paste the jar file into a web and flip because that's a special class path

07:19.820 --> 07:22.280
directory that your project will use.

07:22.790 --> 07:23.750
And that's basically it.

07:23.750 --> 07:28.910
So you've successfully downloaded the JSF Jar file and added it to your JSF project.

07:32.060 --> 07:32.330
All right.

07:32.330 --> 07:34.190
So this is just a short video here.

07:34.190 --> 07:38.120
So in summary, what we did was we discussed the need for validation.

07:38.120 --> 07:42.470
And then we also got an overview of the GSF validation features.

07:42.470 --> 07:47.780
And then we went through and we took care of some housekeeping as far as creating our new Validate demo

07:47.780 --> 07:48.590
project.

07:51.650 --> 07:55.190
So this wraps up the video and validating JSF forms here.

07:55.190 --> 08:00.080
I really just gave you an overview and as I mentioned earlier, I'm going to break up all these topics

08:00.080 --> 08:01.310
in a separate videos.

08:01.310 --> 08:06.140
And so we'll actually do a drill down or a deep dive into each one of those validation rules.

08:06.140 --> 08:10.430
And I'll show you a complete example that works end to end with the validation.

08:10.430 --> 08:15.350
So we have a lot of fun stuff in store, so stay tuned for the next set of validation videos.
