You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Joey <jo...@gmail.com> on 2008/05/30 10:31:33 UTC
How to use a key as "variable" in resource file (Struts2)
Hi,
I just wondering how to use a key as "variable" in a resource file.
(like in build.properties, we can define a key as a variable), but I
don't know how to make it with Struts2.
anybody know how to make it?
ex.
////////////////////////////////////////////
app.name=hello world
welcome.msg=${app.name} is my first application!!!
///////////////////////////////////////////
***I know above grammar is incorrect, I just want to let you know what I want...
welcome.jsp
//////////////////////////////////////////
<s:text name="welcome.msg" />
//////////////////////////////////////////
output in browser
/////////////////////////////////////////
hello world is my first application!!!
/////////////////////////////////////////
Thanks
Joey
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: How to use a key as "variable" in resource file (Struts2)
Posted by Bob Tiernay <bt...@hotmail.com>.
I don't think this is currently supported in struts2. I too wish that this
feature existed :)
However, with some muscle, you can do something like:
app.name=hello world
welcome.msg={0} is my first application!!!
<s:text name="welcome.msg">
<s:param><s:text name="app.name"/></s:param>
</s:text>
--------------------------------------------------
From: "Joey" <jo...@gmail.com>
Sent: Friday, May 30, 2008 4:31 AM
To: "Struts Users Mailing List" <us...@struts.apache.org>
Subject: How to use a key as "variable" in resource file (Struts2)
> Hi,
>
> I just wondering how to use a key as "variable" in a resource file.
> (like in build.properties, we can define a key as a variable), but I
> don't know how to make it with Struts2.
> anybody know how to make it?
>
> ex.
> ////////////////////////////////////////////
> app.name=hello world
> welcome.msg=${app.name} is my first application!!!
> ///////////////////////////////////////////
> ***I know above grammar is incorrect, I just want to let you know what I
> want...
>
> welcome.jsp
> //////////////////////////////////////////
> <s:text name="welcome.msg" />
> //////////////////////////////////////////
>
> output in browser
> /////////////////////////////////////////
> hello world is my first application!!!
> /////////////////////////////////////////
>
> Thanks
>
> Joey
>
> ---------------------------------------------------------------------
> 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: How to use a key as "variable" in resource file (Struts2)
Posted by Joey <jo...@gmail.com>.
Thanks Bob, thanks Owen , just tried owen's answer, perfect!!!, that's
it. thank you very much.....
On Fri, May 30, 2008 at 9:19 PM, Owen Berry <ow...@gmail.com> wrote:
> Try this in your properties file:
>
> application.company.shortname=My Company
> application.window.title=$\{getText('application.company.shortname')} Web
> Portal
>
> On Fri, May 30, 2008 at 4:31 AM, Joey <jo...@gmail.com> wrote:
>
>> Hi,
>>
>> I just wondering how to use a key as "variable" in a resource file.
>> (like in build.properties, we can define a key as a variable), but I
>> don't know how to make it with Struts2.
>> anybody know how to make it?
>>
>> ex.
>> ////////////////////////////////////////////
>> app.name=hello world
>> welcome.msg=${app.name} is my first application!!!
>> ///////////////////////////////////////////
>> ***I know above grammar is incorrect, I just want to let you know what I
>> want...
>>
>> welcome.jsp
>> //////////////////////////////////////////
>> <s:text name="welcome.msg" />
>> //////////////////////////////////////////
>>
>> output in browser
>> /////////////////////////////////////////
>> hello world is my first application!!!
>> /////////////////////////////////////////
>>
>> Thanks
>>
>> Joey
>>
>> ---------------------------------------------------------------------
>> 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: How to use a key as "variable" in resource file (Struts2)
Posted by Owen Berry <ow...@gmail.com>.
Try this in your properties file:
application.company.shortname=My Company
application.window.title=$\{getText('application.company.shortname')} Web
Portal
On Fri, May 30, 2008 at 4:31 AM, Joey <jo...@gmail.com> wrote:
> Hi,
>
> I just wondering how to use a key as "variable" in a resource file.
> (like in build.properties, we can define a key as a variable), but I
> don't know how to make it with Struts2.
> anybody know how to make it?
>
> ex.
> ////////////////////////////////////////////
> app.name=hello world
> welcome.msg=${app.name} is my first application!!!
> ///////////////////////////////////////////
> ***I know above grammar is incorrect, I just want to let you know what I
> want...
>
> welcome.jsp
> //////////////////////////////////////////
> <s:text name="welcome.msg" />
> //////////////////////////////////////////
>
> output in browser
> /////////////////////////////////////////
> hello world is my first application!!!
> /////////////////////////////////////////
>
> Thanks
>
> Joey
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>