File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes Displaying component id for error message Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Java » JSF
Reply Bookmark "Displaying component id for error message" Watch "Displaying component id for error message" New topic
Author

Displaying component id for error message

John Tannel
Greenhorn

Joined: Dec 17, 2010
Posts: 23
Okay,

So where I was previously working we were using Tomcat 6, JSP 2.1, JSF 1.2 using Sun's RI. When we would display error messages using <h:messages> it would show the id of the component where the error occurred.

Now, I am working on a site for a family member. We are using Tomcat 5.5, JSP 2.0 and JSF 1.1 because the web host only lets us use Tomcat 5.5. The error messages do not display the same way, they now only show the error message itself and not any information about which component id caused the error.

Is this because we are using JSF 1.1 instead of 1.2? I believe that is the reason but I thought maybe someone on the forums here could verify. If that is the case, do I have any options besides writing custom validators to include the details myself?

Thanks!

John
Cesar Loachamin
Ranch Hand

Joined: Dec 25, 2010
Posts: 90

Hi John

Yes, the problem is because you are using JSF 1.1 this version display only generic messages, in JSF 1.2 the components have a label attribute the value of this attribute is used in the message showed with <h:messages>, when you do not specify a value for the label attribute the jsf implementation use the ID of the component.

I think the option of custom validator is the best option, but you have another options, for example you can change the text of the standard error using a message bundle but you need to replace all the generic messages, or you can set the type of the properties in the Managed Bean as String and check if they are valid and if not you can add a message it will be displayed in the <h:messages />.



Regards

Cesar


When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
John Tannel
Greenhorn

Joined: Dec 17, 2010
Posts: 23
Cesar,

Thanks for the information! The main reason I wanted that level of detail was so I could have one location for errors, but indicate to the user which component is causing the problem (usually for missing or misformed inputs - $1,234 instead of 1234 for example). I can solve this by simply using separate message components for each input component. It is not quite the low maintenance solution I had hoped for but will work fine nonetheless. Thanks again!

John
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying component id for error message
 
Similar Threads
JavaServer Faces 1.2 and Tomcat 5.5
customizing messages
Will Tomcat eventually support JSF 1.2?
JSF 1.1 vs. JSF 1.2
General problems with some beginner stuff