Hi,
On Mon, Apr 21, 2008 at 5:37 AM, Pranav <[EMAIL PROTECTED]> wrote:
> Hi,
>
> I am new to struts 2 and trying to figure out a problem that I am having
> w.r.t. I18n. My application is supposed to serve multiple clients per hosted
> instance of the application and the requirement is to somehow support the
> requirement of display of client specific text for the same message resource
> key based on the logged in user. E.g. so if an end user is logging on to the
> system on behalf of customer 1 the same key "welcome.user" should display
> message different from what another end user of customer 2 sees for the same
> message resource key. Note that the locale is still the same i.e. US English.
> I was thinking about the following solution:
I don't know if I get it right, but I think the solution is much more simpler.
You mentioned you want to display a different welcome message for each
user. Is this "welcome.user" really that different or is it just
something like "Hi there, dear user [username]!" ?
If so, you can do this with the default <s:text /> tag, by just adding
a <s:param /> to it:
<s:text name="welcome.user">
<s:param value="user.name" />
</s:text>
The message in the bundle then has to look like this:
welcome.user=Hi there, dear user {0}!
You can add arbitrary parameters to message texts, and even format
numbers and so on. The Text-component uses the Default
java.text.MessageFormat class to render the message including the
parameters.
Cheers,
-Ralf
> Solution: I will extend ActionSupport class and all its getText method such
> that each key will be prefixed by something unique to the customer like
> customer_id before the lookup and each messageresouce file will define the
> same key multiple times with the customer_id as prefix as needed. E.g.
> cust1.welcome.user, cust2.welcome.user etc.
>
> Now my questions are:
> 1) If I do the above, do I always have to use the getText way of looking up
> the messages? If I use the key attribute of the UI tags, will the overridden
> getText methods be still called?
> 2) Also is there any major problem with the approach above to solve the
> particular problem I am having?
>
> Thanks and regards
> Pranav
>
>
>
>
>
>
> ____________________________________________________________________________________
> Be a better friend, newshound, and
> know-it-all with Yahoo! Mobile. Try it now.
> http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ
>
> ---------------------------------------------------------------------
> 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]