On 1/21/07, JS Portal Support <[EMAIL PROTECTED]> wrote:

Hi,

My backing beans set some info messages though calling the
.info("message").
The messages I set however are ResourceBundle id's. In my JSP's I then
want
to collect the id and present the message. I have:

<h:messages layout="table" globalOnly="true" showDetail="false"
showSummary="true" rendered="#{! empty facesContext.maximumSeverity}"/>

Which now nicely displays my i18n id's.


Aren't they pretty?  :-)

How can I alter it so that my proper
localized messages are shown?

All my i18n is setup and things like:
<h:outputText value="#{labels['my.label.id']}" />
Work as they should.


The simplest approach is to use the tried and true techniques of Java
internationalization, along these lines:

   public class MyBackingBean extends AbstractViewController {

       private static ResourceBundle bundle =
         ResourceBundle.getBundle("com.mycompany.mypackage.MyBundle");
       ...
       public String myAction() {
           ...
           info(bundle.getString("my.message.key"));
           ...
       }

   }

If the resource bundle name listed here is the same as the one you used in
your <f:loadBundle> tag, then you are easily able to leverage exactly the
same localized messages as you are using for the JSP page itself.

If you also need to do parameter replacement in the localized messages, you
should take a look at the org.apache.shale.util.Messages utility class in
the shale-core module.

Craig


Regards,
Joost Schouten




Reply via email to