L.10 Sample of Bean Validation and CDI integration application
The sample program using the Bean Validation and CDI integration application is stored in the following directory:
Application-Server-installation-directory\CC\examples\bv_cdi
This subsection gives an overview of the sample and describes the execution procedure.
- Organization of this subsection
(1) Overview of the sample program of Bean Validation and CDI integration application
Thi sample program provides a sample combining Bean Validation, CDI, and JSF.
With the sample Bean Validation and CDI application, the following settings must be implemented before you execute the sample:
-
Setting up the class path to usrconf.cfg for using the JSF
-
Setting up the permissions to access server.policy for using CDI
For details on server.policy, see 2.2.4 server.policy (Security policy file for J2EE servers) in the uCosminexus Application Server Definition Reference Guide.
The following figure shows the Application-Server-installation-directory\CC\examples\bv_cdi configuration.
(2) Execution procedure of the sample program of Bean Validation and CDI integration application
The procedure for executing the sample program is as follows:
(a) Compiling the sample program
Use the batch file (compile.bat) provided with the sample to compile the sample program. This batch file creates a WAR file (paramcheck.war) and EAR file (paramcheck.ear).
(b) Setting the J2EE server
(c) Customizing the J2EE server
(d) Starting the J2EE server
(e) Deploying the application
See Appendix L.1(5) Importing, setting and starting the application.
(f) Executing the application
Start the browser and specify the following string in the URL to execute the application:
http://computer-name:port-number/paramcheck/
If the port number has been customized, specify the customized port-number.
The following figure shows an example execution of the sample program of Bean Validation and CDI integration application.
Click the Submit button to display the validation results in the message output location.
The following table describes the message output conditions and the output messages.
No. |
Condition |
Output message#1 |
---|---|---|
1 |
When the validation is successful |
Validation Successful! |
2 |
When a string of 16 or more characters is entered in the Name textbox#2 |
size must be between 0 and 15 The name must be no more than 15 characters. |
3 |
When a value smaller than 0 is entered in the Age textbox#2 |
must be greater than or equal to 0 The age is less than the minimum value. Enter a number from 0 through 120. |
4 |
When a value greater than 120 is entered in the Age textbox#2 |
must be less than or equal to 120 The age exceeds the maximum value. Enter a number from 0 through 120. |
5 |
When a value that cannot be converted into a number is entered in the Age textbox#2 |
For your age, enter a number (0 to 120). |
6 |
When an exception occurs in the validation processing |
Validation Failed. |