Customizing a Standard Validator Message

A Visual Web Pack user wrote a most excellent question to the nbj2ee alias: I used this tutorial "Customizing a Standard Validator Message" for customizing message boxes but is not working. The link is: http://developers.sun.com/prodtech/javatools/jscreator/learning/tutorials/2/custommessage.html

We are in the process of making Visual Web Pack equivalents of the Sun Java Studio Creator tutorials, but do not plan to push the next set of tutorials for awhile. In addition, we decided to combine the validator, converter, and custom message tutorials, so that one will take longer than the other.

So, in the meantime, you can use the Sun Java Studio Creator tutorial with the following exceptions.

  • In the Creating a Resouce Bundle section, instead of choosing File > New Item in Step 1, choose File > New File. Then select Other in the Categories pane, and select Properties File in the File Types pane.
  • In step 5 of the same section, browse down to CustomMessage > src > java > custommessage.

HOWEVER, and this is a sweet however, JavaServer Faces 1.2 offers a new alternative. The above method customizes the message for the whole web application. But what if you want a specific message for a specific field? With 1.2, you can add the following code to your Java source to set the required message for just this text field component:

textField1.setRequiredMessage("You must enter your favorite flavor.");

In my simple test, I put this in the prerender method.

You can also customize a component's converterMessage and validatorMessage.

Thank you Lark for helping with this one!.

Comments:

symbol : method setRequiredMessage(java.lang.String)
location: class com.sun.rave.web.ui.component.TextField
numeroIdentificacion.setRequiredMessage("You must enter your favorite flavor.");
1 error

Posted by Diego Fernández on November 08, 2007 at 05:34 AM PST #

Post a Comment:
Comments are closed for this entry.
About

divas

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today