You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Ajaya Agrawalla <AA...@strllc.com> on 2005/08/31 22:32:17 UTC
Specifying MessageResource for Title information.
Folks,
I am trying to have all my form fields to have a title. The way I
approached this was to pass title information to the html:* tags like below.
<html:text bundle="hints" titleKey="somekey" properties="some" />
I have the hints.properties file in the classes folder.
I separated all the title related keys to hints.properties. The problem
with this approach is I have to specify the bundle information every time I
have pass title information. The only other way I could get away from
passing bundle info is to put the keys in ApplicationResource file. But i
really wanted to keep it separate. We envision having title information in
multiple languages.
Anyone have any better idea??
Thanks
AJ
Re: Specifying MessageResource for Title information.
Posted by Kishore Senji <ki...@gmail.com>.
one way is to define a CustomMessageResources and a
CustomMessageResourcesFactory to take care of this. The basic idea is that
we would define something like this in the struts-config.xml
<message-resources
parameter="hints,otherhints,ApplicationResources"
factory="com.a.b.c.CustomMessageResourcesFactory"
null="true"/>
and let our CustomMessageResources in it's loadBundle method parse the
parameter with the "," delimiter and loadBundles for all the properties
files. One thing to note here would be that although they would be different
properties files for us, it would get compiled as a single Map so, any
properties with the same key will get silently overridden. (having a unique
prefix for a given property file should take of this)
Take a look at
http://javaboutique.internet.com/tutorials/Dynaform/index-7.html
Although the author overrode the Servlet there in his implementation, just
providing a new factory to create your Custom Message Resources should
suffice.
On 8/31/05, Ajaya Agrawalla <AA...@strllc.com> wrote:
>
> Folks,
>
> I am trying to have all my form fields to have a title. The way I
> approached this was to pass title information to the html:* tags like
> below.
>
> <html:text bundle="hints" titleKey="somekey" properties="some" />
>
> I have the hints.properties file in the classes folder.
>
> I separated all the title related keys to hints.properties. The problem
> with this approach is I have to specify the bundle information every time
> I
> have pass title information. The only other way I could get away from
> passing bundle info is to put the keys in ApplicationResource file. But i
> really wanted to keep it separate. We envision having title information in
> multiple languages.
>
> Anyone have any better idea??
>
> Thanks
>
> AJ
>
>
>