-
1. Re: Why control IDs in validation messages?
pmuir Dec 6, 2007 5:20 PM (in response to igx89)Set the correct message in messages.properties
javax.faces.component.UIInput.REQUIRED=value is required
-
2. Re: Why control IDs in validation messages?
igx89 Dec 6, 2007 5:23 PM (in response to igx89)But if I do that, maybe changing it to "required value", wouldn't that just change the resulting error to "formId:panelId:controlId: Validation Error: required value"? That doesn't help at all :/
-
3. Re: Why control IDs in validation messages?
whafrog Dec 6, 2007 6:39 PM (in response to igx89)The default messages are parameterized, I think the form control is {2}. You can include these parameters or not when you override.
-
4. Re: Why control IDs in validation messages?
gsegura Dec 6, 2007 7:54 PM (in response to igx89)I experienced this too, I started from jpa example. At first the message displayed correct (with no Id).
Although it doesn't seems related (and I didn't have time find out exactly the reason) I think it was about messing around with the default language and not including the proper messages_XX.properties in WEB-INF/classes.
After correcting that error in my ant script I noticed the ids in the messages were gone, but again, didn't have a chance to confirm if that was in fact the reason. I suspected of that because other related things remained equal. -
5. Re: Why control IDs in validation messages?
igx89 Dec 7, 2007 2:18 PM (in response to igx89)Thanks for the help guys. Here are the different possible fixes I've found, for reference:
1. In WEB_INF/classes/messages_XX.properties, put:javax.faces.component.UIInput.REQUIRED=Value is required
The default value is "{0}: Validation Error: Value is required."
2. Use the "label" attribute on the input controls to replace"formId:containerId:controlId" with a friendly name.
3. Use the "requiredMessage" attribute on the input controls to completely override the REQUIRED message. This is what I ended up doing. -
6. Re: Why control IDs in validation messages?
ruettimac Dec 29, 2007 3:34 AM (in response to igx89)I am fighting with the same problem. I have the following setup:
<?xml version="1.0" encoding="UTF-8"?> <faces-config version="1.2" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"> <!-- Facelets Setup --> <application> <view-handler>com.sun.facelets.FaceletViewHandler</view-handler> <locale-config> <default-locale>en</default-locale> <supported-locale>de</supported-locale> <supported-locale>de_CH</supported-locale> </locale-config> </application> </faces-config>
<?xml version='1.0' encoding='UTF-8' ?> <!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://jboss.com/products/seam/taglib" xmlns:f="http://java.sun.com/jsf/core" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html"> <head> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" /> <title>Training Plattform Register Start</title> <link href="css/screen.css" rel="stylesheet" type="text/css" /> </head> <body> <ui:composition template="template.xhtml"> <ui:define name="content"> <h:form id="register"> <s:validateAll> <f:facet name="aroundInvalidField"> <s:span styleClass="errors"/> </f:facet> <f:facet name="afterInvalidField"> <s:div styleClass="errors"> <s:message /> </s:div> </f:facet> <div class="entry"> <div class="label"> <h:outputText value="#{messages.label_firstName}" /> </div> <div class="input"> <s:decorate id="firstNameDecorate"> <h:inputText id="firstName" value="#{customer.firstName}" required="true" /> </s:decorate> </div> </div> </div> </s:validateAll> <div class="entry errors"> <h:messages globalOnly="true"/> </div> <div class="input"> <h:commandButton id="register" value="#{messages.button_register}" action="#{customerRegistration.preRegisterCustomer}" /> </div> </h:form> </ui:define> </ui:composition> </body> </html>
@NotNull @Length(max = 50) public String getFirstName() { return mFirstName; }
I do not see a problem here and no difference between the hotel booking example. But, In my case the formid,containerid and controlid are displayed before the validation message. I did not found a reasonable resolution to this problem. Anyone?
Regards,
Cyrill -
7. Re: Why control IDs in validation messages?
ruettimac Dec 29, 2007 3:38 AM (in response to igx89)The outcome for a german browser is:
Vorname:
register:firstNameDecorate:firstName: Validierungs-Fehler: Wert wird benötigt. -
8. Re: Why control IDs in validation messages?
igx89 Dec 29, 2007 10:46 AM (in response to igx89)Did you see my previous post? There are (at least) three solutions available for that problem.
-
9. Re: Why control IDs in validation messages?
ruettimac Dec 29, 2007 10:53 AM (in response to igx89)Please can you explain solution 2 & 3 a litte bit further? I do not know what you mean. The input component has no such attribute for instance.
Thank you very much! -
10. Re: Why control IDs in validation messages?
ruettimac Dec 29, 2007 4:23 PM (in response to igx89)My Facelets-Editor just did not showed me those two attributes - but they are listed in the JSF-Javadoc:
- label --> The error output is still very noise, but not so cryptical as before
- requiredMessage --> I do a lot of work (translations) I not want to do again
Maybe I should dive a bit into the code ... -
11. Re: Why control IDs in validation messages?
ruettimac Dec 30, 2007 3:15 AM (in response to igx89)I just discovered, that the validation messages from hibernate validator are displayed as in the hibernate validator message bundle except for instance the @NotNull - this is coming from the JSF framework because I have to switch on the attribute required="true". I have now modified
javax.faces.component.UIInput.REQUIRED=Value is required.
to have an uniform message for each input field. For me, this is the easiest way. For me, the validation thing it is still not transparent because some things come from the JSF Validation Framework and some pieces from hibernate validator framework. Why that is clear because of the way the frameworks are plugged in into seam and where the validation occures. Maybe there is a way to uniform this behaviour? -
12. Re: Why control IDs in validation messages?
pmuir Dec 30, 2007 2:03 PM (in response to igx89)required="true"/@NotNull is the only point at which you have to break DRY. This is currently unavoidable, sorry.
-
13. Re: Why control IDs in validation messages?
ristretto Jan 23, 2008 5:52 PM (in response to igx89)I want thank the posters of this thread so much for this topic. I am learning JSF, Seam and Facelets all at the same time. (I have been coding Java since version 1.0.2, but slipped a bit behind the curve as of late.) I didn't see the messages.properties connection in the Seam documentation I have, and I didn't make the connection on my own, so I was totally lost.
I ended up with #3 for now.