You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Bhaarat Sharma <bh...@gmail.com> on 2009/04/17 16:36:08 UTC

Struts.properties question

I  know we can a property file in struts like this

struts.custom.i18n.resources=nameofFile

But is there a way to use multiple properties files? (nameofFile)

we have a lot of labels for our application and if we put everything into
one property file then it seems to get so overwhelmingly huge that its hard
to find anything in it.

Is there a way to over come this problem?

Re: Struts.properties question

Posted by Jim Kiley <jh...@summa-tech.com>.
If you have any power over the data, you should change that so that you are
not getting the SSN as an integer.  It's not a number in any sense of the
word except that it has digits.  You never do math on it.  Save it as a
String if you can.

On Fri, Apr 17, 2009 at 4:20 PM, Bhaarat Sharma <bh...@gmail.com> wrote:

> great!
>
> it worked out for me.
>
> One last question, I was looking at the wiki but it seems like formatting
> is
> only available for numbers and dates.
>
> is it possible to format an SSN?
>
> I am getting the SSN as an integer. but would like to show it as
> ###-##-####
>
> On Fri, Apr 17, 2009 at 10:54 AM, Terry Gardner <Terry.Gardner@sun.com
> >wrote:
>
> >
> > On Apr 17, 2009, at 10:49 AM, Bhaarat Sharma wrote:
> >
> >  so I can create this new property file in the same folder where my
> >> struts.properties file resides or does it have to be in the package
> where
> >> action is.
> >>
> >
> > Good point. I forgot to mention that there is a search hierarchy. I
> usually
> > put the properties
> > files in the same directory as the action, but they can also be "up the
> > chain". So, if my Action class is
> > com.slamd.struts2.actions.SlamdStartServerResultAction.java,
> > then I put the SlamdStartServerResultAction_en.properties file in
> > <srcRoot>com/slamd/struts2/actions.
> >
> >
> >> so if my action name is XXX.java the property file will be
> >> XXX_en.properties
> >> and the properties file will be picked automatically or does it require
> >> any
> >> changes in struts.properties? does it have to be registered there?
> >>
> >
> > Picked automagically by getText(). Remember to change the "_en" part to
> the
> > two letter code for the language. I only speak English - and that badly -
> > so mine are all
> > "_en" for the moment.
> >
> >
> >
> >> Thanks!!
> >>
> >> On Fri, Apr 17, 2009 at 10:44 AM, Terry Gardner <Terry.Gardner@sun.com
> >> >wrote:
> >>
> >>  The resource bundles can also be in files named after the Action, for
> >>> example, SlamdStartServerResultAction_en.properties, which contains
> keys
> >>> and
> >>> values (English) for the Action SlamdStartServerResultAction.java
> >>>
> >>>
> >>> On Apr 17, 2009, at 10:36 AM, Bhaarat Sharma wrote:
> >>>
> >>> I  know we can a property file in struts like this
> >>>
> >>>>
> >>>> struts.custom.i18n.resources=nameofFile
> >>>>
> >>>> But is there a way to use multiple properties files? (nameofFile)
> >>>>
> >>>> we have a lot of labels for our application and if we put everything
> >>>> into
> >>>> one property file then it seems to get so overwhelmingly huge that its
> >>>> hard
> >>>> to find anything in it.
> >>>>
> >>>> Is there a way to over come this problem?
> >>>>
> >>>>
> >>>
> >>> ---------------------------------------------------------------------
> >>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> >>> For additional commands, e-mail: user-help@struts.apache.org
> >>>
> >>>
> >>>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> > For additional commands, e-mail: user-help@struts.apache.org
> >
> >
>



-- 
Jim Kiley
Senior Technical Consultant | Summa
[p] 412.258.3346
http://www.summa-tech.com

Re: Struts.properties question

Posted by Bhaarat Sharma <bh...@gmail.com>.
great!

it worked out for me.

One last question, I was looking at the wiki but it seems like formatting is
only available for numbers and dates.

is it possible to format an SSN?

I am getting the SSN as an integer. but would like to show it as ###-##-####

On Fri, Apr 17, 2009 at 10:54 AM, Terry Gardner <Te...@sun.com>wrote:

>
> On Apr 17, 2009, at 10:49 AM, Bhaarat Sharma wrote:
>
>  so I can create this new property file in the same folder where my
>> struts.properties file resides or does it have to be in the package where
>> action is.
>>
>
> Good point. I forgot to mention that there is a search hierarchy. I usually
> put the properties
> files in the same directory as the action, but they can also be "up the
> chain". So, if my Action class is
> com.slamd.struts2.actions.SlamdStartServerResultAction.java,
> then I put the SlamdStartServerResultAction_en.properties file in
> <srcRoot>com/slamd/struts2/actions.
>
>
>> so if my action name is XXX.java the property file will be
>> XXX_en.properties
>> and the properties file will be picked automatically or does it require
>> any
>> changes in struts.properties? does it have to be registered there?
>>
>
> Picked automagically by getText(). Remember to change the "_en" part to the
> two letter code for the language. I only speak English - and that badly -
> so mine are all
> "_en" for the moment.
>
>
>
>> Thanks!!
>>
>> On Fri, Apr 17, 2009 at 10:44 AM, Terry Gardner <Terry.Gardner@sun.com
>> >wrote:
>>
>>  The resource bundles can also be in files named after the Action, for
>>> example, SlamdStartServerResultAction_en.properties, which contains keys
>>> and
>>> values (English) for the Action SlamdStartServerResultAction.java
>>>
>>>
>>> On Apr 17, 2009, at 10:36 AM, Bhaarat Sharma wrote:
>>>
>>> I  know we can a property file in struts like this
>>>
>>>>
>>>> struts.custom.i18n.resources=nameofFile
>>>>
>>>> But is there a way to use multiple properties files? (nameofFile)
>>>>
>>>> we have a lot of labels for our application and if we put everything
>>>> into
>>>> one property file then it seems to get so overwhelmingly huge that its
>>>> hard
>>>> to find anything in it.
>>>>
>>>> Is there a way to over come this problem?
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>>> For additional commands, e-mail: user-help@struts.apache.org
>>>
>>>
>>>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Struts.properties question

Posted by Terry Gardner <Te...@Sun.COM>.
On Apr 17, 2009, at 10:49 AM, Bhaarat Sharma wrote:

> so I can create this new property file in the same folder where my
> struts.properties file resides or does it have to be in the package  
> where
> action is.

Good point. I forgot to mention that there is a search hierarchy. I  
usually put the properties
files in the same directory as the action, but they can also be "up  
the chain". So, if my Action class is
com.slamd.struts2.actions.SlamdStartServerResultAction.java,
then I put the SlamdStartServerResultAction_en.properties file in
<srcRoot>com/slamd/struts2/actions.

>
> so if my action name is XXX.java the property file will be  
> XXX_en.properties
> and the properties file will be picked automatically or does it  
> require any
> changes in struts.properties? does it have to be registered there?

Picked automagically by getText(). Remember to change the "_en" part  
to the
two letter code for the language. I only speak English - and that  
badly - so mine are all
"_en" for the moment.

>
> Thanks!!
>
> On Fri, Apr 17, 2009 at 10:44 AM, Terry Gardner  
> <Te...@sun.com>wrote:
>
>> The resource bundles can also be in files named after the Action, for
>> example, SlamdStartServerResultAction_en.properties, which contains  
>> keys and
>> values (English) for the Action SlamdStartServerResultAction.java
>>
>>
>> On Apr 17, 2009, at 10:36 AM, Bhaarat Sharma wrote:
>>
>> I  know we can a property file in struts like this
>>>
>>> struts.custom.i18n.resources=nameofFile
>>>
>>> But is there a way to use multiple properties files? (nameofFile)
>>>
>>> we have a lot of labels for our application and if we put  
>>> everything into
>>> one property file then it seems to get so overwhelmingly huge that  
>>> its
>>> hard
>>> to find anything in it.
>>>
>>> Is there a way to over come this problem?
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
>> For additional commands, e-mail: user-help@struts.apache.org
>>
>>


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts.properties question

Posted by Bhaarat Sharma <bh...@gmail.com>.
so I can create this new property file in the same folder where my
struts.properties file resides or does it have to be in the package where
action is.

so if my action name is XXX.java the property file will be XXX_en.properties
and the properties file will be picked automatically or does it require any
changes in struts.properties? does it have to be registered there?

Thanks!!

On Fri, Apr 17, 2009 at 10:44 AM, Terry Gardner <Te...@sun.com>wrote:

> The resource bundles can also be in files named after the Action, for
> example, SlamdStartServerResultAction_en.properties, which contains keys and
> values (English) for the Action SlamdStartServerResultAction.java
>
>
> On Apr 17, 2009, at 10:36 AM, Bhaarat Sharma wrote:
>
>  I  know we can a property file in struts like this
>>
>> struts.custom.i18n.resources=nameofFile
>>
>> But is there a way to use multiple properties files? (nameofFile)
>>
>> we have a lot of labels for our application and if we put everything into
>> one property file then it seems to get so overwhelmingly huge that its
>> hard
>> to find anything in it.
>>
>> Is there a way to over come this problem?
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>

Re: Struts.properties question

Posted by Terry Gardner <Te...@Sun.COM>.
The resource bundles can also be in files named after the Action, for  
example, SlamdStartServerResultAction_en.properties, which contains  
keys and values (English) for the Action  
SlamdStartServerResultAction.java

On Apr 17, 2009, at 10:36 AM, Bhaarat Sharma wrote:

> I  know we can a property file in struts like this
>
> struts.custom.i18n.resources=nameofFile
>
> But is there a way to use multiple properties files? (nameofFile)
>
> we have a lot of labels for our application and if we put everything  
> into
> one property file then it seems to get so overwhelmingly huge that  
> its hard
> to find anything in it.
>
> Is there a way to over come this problem?


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org


Re: Struts.properties question

Posted by Dave Newton <ne...@yahoo.com>.
Bhaarat Sharma wrote:
> I  know we can a property file in struts like this
> 
> struts.custom.i18n.resources=nameofFile
> 
> But is there a way to use multiple properties files? (nameofFile)

IIRC this is a comma-separated list (see [1] for example); AFAIK you can 
have as many as you want.

That said, messages can be put in any of the places used for I18N [2]: 
package.properties, action- or interface-specific property files, and so 
on: depending on how your application is structured this may be a better 
way. I prefer this over the previous method, but my apps are usually 
structured to allow it.

Using a resource file editing tool can also help.

Dave

[1] http://struts.apache.org/2.x/docs/strutsproperties.html
[2] http://struts.apache.org/2.x/docs/localization.html

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org