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?
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 />.
When a dream is ending because to come true - OCPJP 6,7. OCE JPA EE6. MCTS
Joined: Dec 17, 2010
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!