myfaces-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Leonardo Uribe (JIRA)" <...@myfaces.apache.org>
Subject [jira] [Commented] (MYFACES-4055) Localized JSF error and information messages not displayed
Date Tue, 09 Aug 2016 17:14:20 GMT

    [ https://issues.apache.org/jira/browse/MYFACES-4055?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15413864#comment-15413864
] 

Leonardo Uribe commented on MYFACES-4055:
-----------------------------------------

I do not think this could be considered a bug. The reason is it is not supposed to set "javax.faces.Messages"
bundle in faces-config.xml, because it is already the default bundle. In other words, it is
supposed the resources are in jsf jars. 

If you have a new translation of javax.faces.Messages, you can contribute and attach the translation
to this issue, so it could be applied to myfaces codebase. On the mean time, you could repackage
myfaces jars and include the required file.

> 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.3.4#6332)

Mime
View raw message