commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Craig McClanahan <craig...@apache.org>
Subject Re: [RESOURCES] Messages vs. regular properties
Date Thu, 01 Dec 2005 23:05:11 GMT
On 12/1/05, Michael Jouravlev <jmikus@gmail.com> wrote:
>
> On 11/30/05, Niall Pemberton <niall.pemberton@gmail.com> wrote:
> > On 12/1/05, Michael Jouravlev <jmikus@gmail.com> wrote:
> > > Do I miss something or messages and resources are incompatible? From
> > > my point of view they are basically the same thing. Differences are:
> > >
> > >  * resources can be anything, messages can be only strings
> > >  * messages take parameters to stick into placeholders
> >
> > If were talking in Commons Resources terms then Resources and Message
> > are different things - a Message is the representation of the key to a
> > resource - Resources are what resolve those keys into the resource
> > object.
>
> Umm... So you are saying that I should use Message(s) for both error
> messages and regular localised strings. Makes sense. How about
> Messages to implement List? I know it sucks to implement all List
> methods, but JSTL calls get("bla") for lists if I use something like
> ${list["bla"]} in my JSP page. I think it would really simplify
> things, because now I have to write
> <li><i>
>   <%= ((Messages)session.getAttribute("MSGS")).getMessage("label.user") %>
> </i></li>
> which is OK, but too long. Or maybe you can suggest a better way to
> display messages?


FWIW, JavaServer Faces addresses this by exposing a resource bundle as a Map
(not a List):

    <f:loadBundle var="messages" bundlename="
com.mycompany.mypackage.Messages"/>

so you can say things like:

    <h:outputLabel for="username" value="#{messages['label.user']}"/>

Even with JSTL expressions, I think a Map would be more useful than a List.

Michael.


Craig

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message