Ok, so you just have the {0} {1} parameters in the resource bundle's
message itself, and then you use those to create your own text string.
 That makes pretty good sense.

Thanks.


On Wed, 30 Mar 2005 16:39:53 +0200, Enrique Medina <[EMAIL PROTECTED]> wrote:
> Simply, because previously I have extracted that string using a
> ResourceBundle with a key ;-)
> 
>                FacesContext facesContext = FacesContext.getCurrentInstance();
>                String bundleName = 
> facesContext.getApplication().getMessageBundle();
>                ResourceBundle bundle = null;
> 
>                if (bundleName != null)
>                {
>                        String summary = null;
>                        String detail = null;
> 
>                        locale = (locale == null) ? 
> facesContext.getViewRoot().getLocale()
>                                        : locale;
>                        bundle = ResourceBundle.getBundle(bundleName, locale,
>                                        getCurrentClassLoader(params));
> 
>                        try
>                        {
>                                summary = bundle.getString(messageId);
>                                detail = bundle.getString(messageId + 
> ".detail");
>                        }
>                        catch (MissingResourceException e)
>                        {
>                        }
> 
> On Wed, 30 Mar 2005 08:21:52 -0600, Heath Borders
> <[EMAIL PROTECTED]> wrote:
> > But how would you identify that MessageFormat with a key?
> >
> >
> > On Wed, 30 Mar 2005 15:45:47 +0200, Enrique Medina <[EMAIL PROTECTED]> 
> > wrote:
> > > I think I'll have to create a new tag ;-)
> > >
> > >
> > > On Wed, 30 Mar 2005 09:35:48 +0200, Enrique Medina <[EMAIL PROTECTED]> 
> > > wrote:
> > > > Well, it can be done using a MessageFormat:
> > > >
> > > > MessageFormat mf = null;
> > > > if (params != null)
> > > > {
> > > >         mf = new MessageFormat("This is a message for {0}", locale);
> > > >         summary = mf.format(params, new StringBuffer(), null)
> > > >                         .toString();
> > > > }
> > > >
> > > > So why couldn't it be done using a tag?
> > > >
> > > > On Tue, 29 Mar 2005 08:50:34 -0600, Heath Borders
> > > > <[EMAIL PROTECTED]> wrote:
> > > > > I've been wondering about this, too.  The problem is that it doesn't
> > > > > seem like the java.util.ResourceBundle class accepts parameters (all
> > > > > the parameterized messages are actually FaecsMessages), so I'm not
> > > > > sure if there is a standard way to do that.
> > > > >
> > > > >
> > > > > On Tue, 29 Mar 2005 12:21:00 +0200, Enrique Medina <[EMAIL 
> > > > > PROTECTED]> wrote:
> > > > > > Hi,
> > > > > >
> > > > > > There are some ocassions where it's very useful to be able to define
> > > > > > some params to these tags, as the text to be shown is from a
> > > > > > ResourceBundle and has params in the form:
> > > > > >
> > > > > > "This is a message for {0}"
> > > > > >
> > > > > > or something like this. Does anybody know how to handle this
> > > > > > situation? I've tried something like this:
> > > > > >
> > > > > > <h:messages value="#{messages.MessageWithParams}" >
> > > > > > <f:param value="#{user.name}"/>
> > > > > > </h:messages>
> > > > > >
> > > > > > but with no success.
> > > > > >
> > > > > > Any ideas?
> > > > > >
> > > > >
> > > > > --
> > > > > -Heath Borders-Wing
> > > > > [EMAIL PROTECTED]
> > > > >
> > > >
> > >
> >
> > --
> > -Heath Borders-Wing
> > [EMAIL PROTECTED]
> >
> 


-- 
-Heath Borders-Wing
[EMAIL PROTECTED]

Reply via email to