-
1. Re: Resolving Messages
lvdberg Nov 1, 2009 12:12 PM (in response to walterjwhite)Hi,
messages should be accesible on the classpath and I usually place them in the class-dir under WEBINF. Further more the application should recognize that the browser only talks enUS.
Leo
-
2. Re: Resolving Messages
walterjwhite Nov 1, 2009 3:10 PM (in response to walterjwhite)Thanks Leo, I figured it was something simple like that. I'm just testing that now, I'll post the results in a bit.
-
3. Re: Resolving Messages
walterjwhite Nov 1, 2009 3:14 PM (in response to walterjwhite)Awesome - that was it. It works great now.
Walter
-
4. Re: Resolving Messages
walterjwhite Nov 4, 2009 5:56 PM (in response to walterjwhite)Leo, I should have posted back sooner. Actually, it works well, but for validation, it does not work. Instead of getting:
Email Address is not a valid email address
I get:
value is not a valid email address
What else do I need to change to make those work again?
Walter
-
5. Re: Resolving Messages
lvdberg Nov 5, 2009 9:24 AM (in response to walterjwhite)Hi Walter,
I've you have defined for instance the following in your message file:
validator.email={0} must be a well-formed email address person_email = eMail
And let's assume you are using the following standard Seam-way for input and validation:
<s:decorate id="emailField" template="../layout/edit.xhtml"> <ui:define name="label">#{messages['person_email']}</ui:define> <h:inputText value="#{yourBean.email}" label="#{messages['person_email']}"> <a4j:support event="onblur" reRender="emailField" ajaxSingle="true" bypassUpdates="true" eventsQueue="inputQueue" /> </h:inputText> </s:decorate>
After validation (and it's not ok) the message is displayed and the label works as value for the {0} placeholder.
Because this is also coming from the message bundle the label-value gets replaced with a localized string.Leo
-
6. Re: Resolving Messages
walterjwhite Nov 6, 2009 4:31 AM (in response to walterjwhite)Leo,
This may be a dumb question, but you have to define your own edit layout right like this:
(this is my edit.xhtml)
|<ui:composition xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:s="http://jboss.com/products/seam/taglib"> <div class="field"> <s:label styleClass="label #{invalid?'errors':''}"> <ui:insert name="label"/> <s:span styleClass="required" rendered="#{required}">*</s:span> </s:label> <span class="input #{invalid?'errors':''}"> <s:validateAll> <ui:insert/> </s:validateAll> </span> <s:message styleClass="error errors"/> </div> </ui:composition>|
<s:decorate id="firstNameDecorate" template="${decorator.editLayout}"> <ui:define name="label">#{messages['user.firstName']}</ui:define> <h:inputText id="firstName" required="true" value="#{contactBean.firstName}" label="#{messages['user.firstName']}"> <a:support event="onblur" reRender="firstNameDecorate"/> </h:inputText> </s:decorate>
I have user.firstName in my messages.properties. The ${decorator.editLayout} is a property that gets replaced when I run maven.
The labels worked before I must have a wrong property specified somewhere as it was being picked up.
Walter
-
7. Re: Resolving Messages
lvdberg Nov 6, 2009 9:34 AM (in response to walterjwhite)Hi,
If it works with a literal string, it has to do with Facelets, if its still in the code when you render, it will get confused because the ${} is the
old
JSF EL wayLeo
-
8. Re: Resolving Messages
walterjwhite Nov 6, 2009 12:30 PM (in response to walterjwhite)No, it gets pulled out as soon as the resources are processed, so jetty/facelets would never see that.
Walter