-
1. Re: Seam and JSF error message format
msystems Feb 18, 2008 11:38 PM (in response to rao)
registerForm:usernameDecorate:username: Validation Error: Value is required.Is a standard JSF error message from Messages(_xx).properties:
javax.faces.component.UIInput.REQUIRED\={0}: Validation Error: Value is required.
where _xx is a language, e.g. _en for english and _da for danish etc.
You can create you own Messages(_xx).properties and replace standard JSF messages (or other messages) with you own messages, e.g.:
javax.faces.component.UIInput.REQUIRED\=Value is required.
Or you can use Seam to load your custom messages - add the following lines to components.xml:
<core:resource-loader> <core:bundle-names> <value>messages</value> </core:bundle-names> </core:resource-loader>
-
-
3. Re: Seam and JSF error message format
rao Feb 19, 2008 12:59 AM (in response to rao)Ken,
Thanks for your help. Looks like I have some catching up to do on JSF.
-Rao
-
4. Re: Seam and JSF error message format
rstevens Feb 28, 2008 7:55 PM (in response to rao)Yes, but how do I get custom error messages to appear for NotNull values like,
Credit card number is required?
The booking example has this code in booking.java
@NotNull(message="Credit card number is required") @Length(min=16, max=16, message="Credit card number must 16 digits long") @Pattern(regex="^\\d*$", message="Credit card number must be numeric") public String getCreditCard() { return creditCard; }
If I submit the form to book a hotel, it just shows the error message,
value is required
. How do I get the textCredit card number is required
to display?And, how do I get that custom error to display on top of the form?
-
5. Re: Seam and JSF error message format
oneworld95 Aug 21, 2009 4:40 PM (in response to rao)I know this thread is from awhile back, but this can help for anyone who runs into this issue: Add a
converterMessage="Credit card number is required"
to your XHTML tag and the error will display. Not sure why this works, but it did on my project. I had the same issue, where themessage
attribute on the annotations didn't pass through; it would only display the default error message. Maybe someone can shed some light on this. -
6. Re: Seam and JSF error message format
frer Sep 1, 2009 8:07 PM (in response to rao)How would it be possible to change the {0} value. I don't want the full component id path but I'd like to have the attribute name so instead of having an error message like:
registerForm:usernameDecorate:username: Validation Error: Value is required.I'd like to have
username: Validation Error: Value is required.I know how to change the properties files...its really the value of the attribute that is problematic in my case.
Thank you,
Francois
-
7. Re: Seam and JSF error message format
qbit42 Sep 30, 2009 1:09 PM (in response to rao)This is easy to accomplish. Just add label="username" to your inputText and the error message will use the label instead of the id.
-
8. Re: Seam and JSF error message format
frer Sep 30, 2009 3:19 PM (in response to rao)Thanks Matthias you are absolutely right. That does do the trick!
I was looking too far :)