Interesting approach. We are facing the same challenge and fast. We are
basically are creating a shopping mall where each store has it's own look
but the same basic functioning under the hood. We have opted to pursue
moving the "static text" attributes out of the application.resource files
and put them into an application scope prop object bean. The prop object is
basically a n-level nested hashtable. This allows us to strip the hardcoding
out of the jsp so when you retrieve a "static text" attribute for a certain
user you could use:

Title = getprop(dept, title)
Gets the String value back of: HUMAN RESOURCES

Img src=getprop(dept, banner)
Gets the string value back: http://webserver/images/banner1.jpg

Since the prop object is loaded up once when the application starts and
doesn't care how the data is structured you can get pretty intense on what
you store in there as long as the application developer knows the key to get
the value of the property they want out. In our environment, we are going to
initially load from a database table (basically: ID, PARENT_ID, VALUE) and
if there is an edit we update the database directly and bounce the
application or we'll build an admin interface to the app that updates the
database and reloads the whole prop object (or subtree) that way we don't
have to redeploy the app to edit 'static text' or change an image name. This
will allow us to push some of the 'look and feel' customization out to the
client in the future if we want.

We're going to give it a try and see what happens.
Rich


-----Original Message-----
From: David Chelimsky [mailto:[EMAIL PROTECTED] 
Sent: Wednesday, June 04, 2003 7:03 AM
To: Struts Users Mailing List
Subject: Re: Application resources and java


I wouldn't create resources in an Action (I don't even know how), but 
you can access them in an Action. Try this (based on a thread a couple 
of months ago):

=========================
#in application.resources (or wherever you store your messages)
label1.condition1=SOME VALUE label1.condition2=SOME OTHER VALUE

=========================
//in your Action
MessageResources messages = getResources(request);

if (condition == condition1) {
        form.setLabel1(messages.getMessage("label1.condition1");
} else if (condition == condition2) {
        form.setLabel1(messages.getMessage("label1.condition2");
}
//etc, etc

The idea is

Gregory F. March wrote:

>I have an application where a user logs in and what is presented to 
>them depends on what organization they belong to.
>
>Things like the web page title, labels, images, etc. are different for 
>different organizations.
>
>I'm thinking that I'd like to create application resources from the 
>login action that can be referenced with the bean:message tag.  This 
>way, the key is always something like myapp.page.title rather than 
>having to use logic: tags or jsp to determine the appropriate resource.
>
>My questions are:
>
> * Is the the appropriate way to do this sort of thing?
> * Irrespective of the answer to the above, can one create / modify
>   application resources from java? (Like in an action?)
>
>Thanks,
>
>/greg
>
>--
>Gregory F. March    -=-    http://www.gfm.net:81/~march    -=-
AIM:GfmNet
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>
>
>
>
>  
>



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to