You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Jonathan <ja...@i-2000.com> on 2001/05/30 00:58:03 UTC

Resources clarification :^)

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 ActionForm
2) the Action class that works with that ActionForm
3) 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

Thanks 
Jonathan

Re: Resources clarification - is there a work around

Posted by Martin Cooper <ma...@tumbleweed.com>.
Personally, I would have thought that per-page resources would introduce
more problems than they solve. If there is text that needs to be consistent
across pages, it's much better to have it in only one place. Even if keys
are the same across pages, there is no assurance that the text will be. And
when it comes to translation time, all those strings will have to be
translated multiple times - and perhaps not always the same way, especially
with multiple translators working on a large app.

Just my 2 cents...

--
Martin Cooper


----- Original Message -----
From: "Jonathan Asbell" <ja...@i-2000.com>
To: <st...@jakarta.apache.org>
Sent: Wednesday, May 30, 2001 8:01 PM
Subject: Re: Resources clarification - is there a work around


> 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" <pe...@irista.com>
> To: <st...@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
> >
>



Re: Resources clarification - is there a work around

Posted by Jonathan <ja...@i-2000.com>.
Hi Peter.  Read the whole thread and you will see some good examples as to
why I want to do this.

I think I will end up doing some surgery on the struts classes.  I will
associate the page I am forwarding to with a properties file, maybe inside
the struts-config.  That will mean I will have to look at the dom
manipulation which gets the values and ad another group of items (the
associated properties file) to a hashtable or object. I will put the
properties files in the same directory as the jsp page but protected.  I
will try to protect all files that end in ".properties".

I would love to hear suggestions from Niall, Ted, Craig, Hal, Jeff, Nanduri,
Dave etc....


----- Original Message -----
From: "Peter Alfors" <pe...@irista.com>
To: <st...@jakarta.apache.org>
Sent: Thursday, May 31, 2001 10:03 AM
Subject: Re: Resources clarification - is there a work around


> 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" <pe...@irista.com>
> > To: <st...@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
> > >
>


Re: Resources clarification - is there a work around

Posted by Peter Alfors <pe...@irista.com>.
One additional thought.   If you find it easier to have a bundle for each page, then
you could combine both ideas.
Use a more defined naming convention, and combine them into one bundle during your
build.


Peter Alfors wrote:

> 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" <pe...@irista.com>
> > To: <st...@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
> > >

Re: Resources clarification - is there a work around

Posted by Peter Alfors <pe...@irista.com>.
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" <pe...@irista.com>
> To: <st...@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
> >

Re: Resources clarification - is there a work around

Posted by Jonathan Asbell <ja...@i-2000.com>.
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" <pe...@irista.com>
To: <st...@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
>


Re: Resources clarification :^)

Posted by Peter Alfors <pe...@irista.com>.
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