wood burning stoves 2.0*
The moose likes JSF and the fly likes How to display appropriate error message in front of text field Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "How to display appropriate error message in front of text field" Watch "How to display appropriate error message in front of text field" New topic
Author

How to display appropriate error message in front of text field

ram gaurav
Ranch Hand

Joined: Mar 29, 2006
Posts: 208
Hi

I am using standard convertor provide by JSF by default.
Its working fine but please tell me the way that how should i display the appropriate error message in front of particular text field.

Thanks
Regards
Gaurav
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
Configure your own property file for messages.
ram gaurav
Ranch Hand

Joined: Mar 29, 2006
Posts: 208
Thanks for your reply.
I am not talking about custom convertors , i am talking about the standard convertors which we get by default with JSF.Like :



Now like if it is not an Integer then it should display an error message in front of that text field , so i am asking about that how to show that error message.

Thanks
Gaurav
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
I meant to say something like below


[ September 12, 2006: Message edited by: Adeel Ansari ]
Adeel Ansari
Ranch Hand

Joined: Aug 15, 2004
Posts: 2874
You can set application wide custom messages using these configurations

Richard Green
Ranch Hand

Joined: Aug 25, 2005
Posts: 536
You would like to replace the message "Validation Error: Value is required." by "Please enter the required value.".

Create a message bundle file in an appropriate package that you can choose, let's say, the file is called "MyErrors.properties" and is located in "WEB-INF/classes/com/example/i18n", thus the package name is "com.example.i18n".

In this file you write one single line:

javax.faces.component.UIInput.REQUIRED=Please enter the required value.

Now edit the faces configuration file (WEB-INF/faces-config.xml) and add the following entry in the application section:

<application>
<message-bundle>com.example.i18n.MyErrors</message-bundle>
</application>

Restart the web application and submit. If there is a required input field, you will see your customized message.

More details:


MCSD, SCJP, SCWCD, SCBCD, SCJD (in progress - URLybird 1.2.1)
ram gaurav
Ranch Hand

Joined: Mar 29, 2006
Posts: 208
Thanks a lot.
John Betts
Greenhorn

Joined: Oct 15, 2013
Posts: 2
Richard Green wrote:You would like to replace the message "Validation Error: Value is required." by "Please enter the required value.".

Create a message bundle file in an appropriate package that you can choose, let's say, the file is called "MyErrors.properties" and is located in "WEB-INF/classes/com/example/i18n", thus the package name is "com.example.i18n".

In this file you write one single line:

javax.faces.component.UIInput.REQUIRED=Please enter the required value.

Now edit the faces configuration file (WEB-INF/faces-config.xml) and add the following entry in the application section:

<application>
<message-bundle>com.example.i18n.MyErrors</message-bundle>
</application>

Restart the web application and submit. If there is a required input field, you will see your customized message.

More details:


Hi Richard. I am getting well all my internationalized messsages except the overriden JSF messages. Could you help me please?
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15956
    
  19

I don't know if Richard is still around. This thread hasn't been touched since 2006!


Customer surveys are for companies who didn't pay proper attention to begin with.
John Betts
Greenhorn

Joined: Oct 15, 2013
Posts: 2
Tim Holloway wrote:I don't know if Richard is still around. This thread hasn't been touched since 2006!


Thanks anyway Tim
daniele licitra
Ranch Hand

Joined: Apr 08, 2013
Posts: 36

To get customized / localizated message, I defined the resource in faces-config and in top of the page I put


then, I use the bean-like notation:


in the label.properties i have:
username=Username
password=Password
required=required

if password is empty, the message "Password: required" is shown.
in the same way, if i use "${label.username}: ${label.required}"/>, the message "Username: required" is shown.


JPA 2.1.0
Glassfish 3.1->4, Wildfly, Primefaces 3.4->4
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to display appropriate error message in front of text field
 
Similar Threads
Reset of JTextField data
getting the focus back
Need some help customizing this error message
How to display specific error
How can i display error messages just above the text field in a jsp page??