struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Alfors <peter.alf...@irista.com>
Subject Re: Resources clarification - is there a work around
Date Thu, 31 May 2001 14:03:35 GMT
We are currently using two different resource bundles.  One for our messages and
another for our constants (that define
web look and feel).  To do this, we overrode the init() method in the
ActionServlet and added another method to initialize a second bundle into a
different session attribute.
This works well for 2 different bundles, but it would not be practical for a
large number or bundles (one per page).

Maybe there would be a way to initialize all of the page bundles at startup?
Some sort of loop or somethine?
I don't have any suggestions on how this would work, but maybe it is a starting
point??

One supporting reason for a single bundle would be this...  It allows you to
easily keep consistent naming across your app.
For instance, if each of your pages has the label "Id", but then later on you
(or the customer) decide that "Name" is a better choice, you only have to change
it in one place.  There are other situations as well, this is just one.
Also, creating new locales is as simple as handing a single resource bundle over
to your translater, rather than 100 different bundles to duplicate.
As for naming problems, there is a simple solution.  Use a naming strategy for
each key.

<pageName>.<Key>=Value
or
common.<Key>=Value     <-- if this is common across all pages.

HTH,
    Pete


Jonathan Asbell wrote:

> Thanks Pete.  However it just seems strange that Struts just offers one big
> resource file for each Local.  I have developed 3 international sites, and I
> can safely say that when a set of resources are associated with a particular
> page it is much easier to manage than 1 resources for all pages.  Has anyone
> hacked at the Struts code to get around this?  I dont like the concatenating
> idea because it is too easy to have duplicates; and you probably want to use
> the same resource names anyway to keep a consistency.  Anyone else have any
> ideas?
>
> ----- Original Message -----
> From: "Peter Alfors" <peter.alfors@irista.com>
> To: <struts-user@jakarta.apache.org>
> Sent: Wednesday, May 30, 2001 9:33 AM
> Subject: Re: Resources clarification :^)
>
> > You could combine all of your property files during your build.
> > This would allow you to have as many different property files as you
> > want.
> > However, you need to be careful that you do not have duplicate names
> > across multiple files.
> >
> > HTH,
> >     Pete
> >
> > Jonathan wrote:
> >
> > > Hello all.  It appears that the ActionServlet points to a resources
> > > file, and not a ResourceBundle object. Is this true?  The reason is
> > > that I would like to group in the same directory the following:1) a
> > > particular ActionForm2) the Action class that works with that
> > > ActionForm3) the resources (strings) that work with that
> > > ActionForm The reason is that it is much easier to manage the
> > > artifacts on a page by page basis.How can I do this
> > > properly ThanksJonathan
> >

Mime
View raw message