aspose file tools*
The moose likes Other Application Frameworks and the fly likes @NotNull: how to configure validation message Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Frameworks » Other Application Frameworks
Bookmark "@NotNull: how to configure validation message" Watch "@NotNull: how to configure validation message" New topic
Author

@NotNull: how to configure validation message

Rogerio Kioshi
Ranch Hand

Joined: Apr 12, 2005
Posts: 689
Hello,

I'm studying a Seam example application from Seam reference guide:

http://www.redhat.com/docs/manuals/jboss/jboss-eap-4.3/doc/seam/Seam_Reference_Guide/html/Seam_Reference_Guide-Seam_Tutorial-Your_first_Seam_application_the_registration_example.html

When I submit the form, and the fields are not filled out, the following messages are shown:
"j_id2:j_id6: Validation Error: Value is required.
j_id2:j_id8: Validation Error: Value is required.
j_id2:j_id10: Validation Error: Value is required. "

How do I configure the message of each field? I wanted to show something like "It is necessary to input the user name".

The Entity class has the following method:


By the way, the validation message when the user name is not between 5 and 15 characters is working fine.


SCEA 5 (part 1), SCBCD, SCWCD, SCJP, CLP, CLS
Dan Allen
Author
Ranch Hand

Joined: Mar 05, 2003
Posts: 164
Hibernate Validator does not enforce the @NotNull annotation. That is taken care of by JSF. The best way to ensure that you get per-field validation messages is to use the <s ecorate> tag along with the layout/edit.xhtml template provided with seam-gen:



Right now, you are probably displaying them at the top of the page using <h:messages/>. Change that to <h:messages globalOnly="true"/>.

To customize JSF messages, you enter the keys in the messages*.properties files. Again, if you create a seam-gen project, you will see the keys that are in these files. Here are the two keys you want:



Dan Allen | http://mojavelinux.com | Author of Seam in Action - http://mojavelinux.com/seaminaction
Jignesh Patel
Ranch Hand

Joined: Nov 03, 2001
Posts: 626

If you don't want to modify property file
in h:inputText just say requiredMessage="First Name Required"
 
 
subject: @NotNull: how to configure validation message