[
https://issues.apache.org/jira/browse/MYFACES-4055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16198566#comment-16198566
]
Thomas Andraschko commented on MYFACES-4055:
--------------------------------------------
[~lu4242] I think it doesn't hurt if check for for webapplication resources
first?!
> Localized JSF error and information messages not displayed
> ----------------------------------------------------------
>
> Key: MYFACES-4055
> URL: https://issues.apache.org/jira/browse/MYFACES-4055
> Project: MyFaces Core
> Issue Type: Bug
> Components: JSR-344
> Affects Versions: 2.2.10
> Environment: Java 8, TomEE 7, Primefaces 6.0, Omnifaces 2.3
> Reporter: Petras
> Labels: localization, messages
> Attachments: full-submit.png, partial-submit.png
>
>
> I have localized JSF error and information messages as described in JSR-344
> Section "2.5.2.4 Localized Application Messages", which defines how
> applications may provide own JSF messages, and prepared resource bundle
> "javax.faces.Messages". In _faces-config.xml_ I set:
> {{<message-bundle>javax.faces.Messages</message-bundle>}}.
> But these resources are not always used, when value validation in UI input
> component fail. Consider the following snippet which illustrates the issue.
> It contains 2 input text fields, the first one has "required" attribute. The
> second field is validated using Bean Validation framework:
> {code:xml}
> <h:form id="form">
> <p:panel header="Validate">
> <h:panelGrid columns="3" cellpadding="5">
>
> <!-- JSF validation -->
> <h:outputLabel for="client1" value="JSF Validation" />
> <h:inputText id="client1" label="JSF Validation"
> value="#{validationModel.requiredClient}" required="true"/>
> <h:message for="client1" display="both" errorStyle="color: red" />
>
> <!-- Bean validation -->
> <h:outputLabel for="bean0" value="Bean Validation" />
> <h:inputText id="bean0" label="Bean Validation"
> value="#{validationModel.requiredAnnotated}" />
> <h:message for="bean0" display="both" errorStyle="color: red" />
> </h:panelGrid>
> <!-- submit without ajax -->
> <h:commandButton value="Save" action="#{validationModel.save}" />
> <!-- submit with ajax -->
> <h:commandButton value="Save (ajax)"
> actionListener="#{validationModel.save}" >
> <f:ajax execute="form" render="form"/>
> </h:commandButton>
> </p:panel>
> </h:form>
> {code}
> The backing bean:
> {code:java}
> @Named @RequestScoped
> public class ValidationModel implements DecisionProcessable {
> @NotNull @Length(min = 1, max = 64)
> private String requiredAnnotated;
> private String requiredClient;
> // getters and setters
> public void save() {
> System.out.println(this);
> }
> }
> {code}
> If I click the button "Save", which performs full submit, I get localized
> error message. If I click "Save (ajax)", which performs partial submit with
> ajax, the JSF validation error message is not localized.
> I did some debugging and noticed that validation logic uses {{_MessageUtils}}
> class to obtain resource bundle for the messages, but this utility class uses
> FacesContext class ClassLoader to find resource bundle. The problem is that
> this ClassLoader does not always refer to web application classloader. When
> the partial submit is performed, it refers to Tomcat common classloader,
> which surely does not see web application resources.
> The fix probably would be the same as implemented in {{MessageUtils}}, which
> uses Thread.currentThread().getContextClassLoader() on ResourceBundle
> (MYFACES-338).
--
This message was sent by Atlassian JIRA
(v6.4.14#64029)