You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Asad Habib <as...@gmail.com> on 2008/02/20 04:58:45 UTC
Using Variables with Messages in Struts
Hello. How do I represent the following in a message resources file?
Representing a string literal is easy but the following string
contains a link. Can this even be done? I have used variables with the
validator before but there is no validator involved in this case.
Thank you.
Please <a href="login.jsp">click here</a> to sign in.
- Asad
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Using Variables with Messages in Struts
Posted by Adam Hardy <ah...@cyberspaceroad.com>.
If you bear in mind that it's usually best to seperate mark-up and content, then
you would break the string down into smaller parts:
<fmt:message key="please.sign.in.part1"/>
<a href="login.jsp"><fmt:message key="please.sign.in.part2"/></a>
<fmt:message key="please.sign.in.part3"/>
Then the problem is that in some languages you might break the string down
differently. Ideally you would choose a different way of doing it, e.g.
<a href="login.jsp">Please click here to sign in.</a>
or
Please click here to sign in: <a href="login"><img src="nice.gif"/></a>
but if you don't have any choice in the matter, I guess you are stymied.
Generally speaking, HTML in the message resources is best avoided. However it
probably works with the fmt:message tag. I think I've done that before myself.
My last thought is that it might be better to supply the URL to the href as a
parameter
<fmt:message key="please.sign.in"><fmt:param>login.jsp</fmt:param></fmt:message>
please.sign.in=Please <a href="{0}">click here</a> to sign in.
- might make maintenance easier.
Asad Habib on 20/02/08 11:18, wrote:
> Hello Nuwan. Doing it the way you proposed defeats the purpose since I
> have to place this string in a bean first. I would like to retrieve
> this string directly from message resources and display it with the
> html intact. Is there any to do this? Thank you for your suggestion.
>
> - Asad
>
>
>
> On Feb 20, 2008 1:07 AM, Nuwan Chandrasoma <my...@gmail.com> wrote:
>> Hi,
>>
>> why dont you try the <bean:write> tag with filter attribute as false.
>>
>> Thanks,
>>
>> Nuwan
>>
>>
>> Jeromy Evans wrote:
>>> Oh, sorry, I assumed you were using Struts 2. That's a feature of the
>>> default tag library.
>>>
>>> Sorry, I don't know the answer for Struts 1.x
>>>
>>> Asad Habib wrote:
>>>> Hello Jeromy. What tag library are you using for this?
>>>>
>>>> - Asad
>>>>
>>>>
>>>>
>>>> On Feb 19, 2008 11:19 PM, Jeromy Evans
>>>> <je...@blueskyminds.com.au> wrote:
>>>>
>>>>> You may be able to do it with s:property, disabling escaping of the
>>>>> html:
>>>>>
>>>>> <s:property value="getText('some.key')" escape="false"/>
>>>>>
>>>>>
>>>>> Asad Habib wrote:
>>>>>
>>>>>> Hello. How do I represent the following in a message resources file?
>>>>>> Representing a string literal is easy but the following string
>>>>>> contains a link. Can this even be done? I have used variables with the
>>>>>> validator before but there is no validator involved in this case.
>>>>>> Thank you.
>>>>>>
>>>>>> Please <a href="login.jsp">click here</a> to sign in.
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Using Variables with Messages in Struts
Posted by Asad Habib <as...@gmail.com>.
Hello Nuwan. Doing it the way you proposed defeats the purpose since I
have to place this string in a bean first. I would like to retrieve
this string directly from message resources and display it with the
html intact. Is there any to do this? Thank you for your suggestion.
- Asad
On Feb 20, 2008 1:07 AM, Nuwan Chandrasoma <my...@gmail.com> wrote:
> Hi,
>
> why dont you try the <bean:write> tag with filter attribute as false.
>
> Thanks,
>
> Nuwan
>
>
> Jeromy Evans wrote:
> > Oh, sorry, I assumed you were using Struts 2. That's a feature of the
> > default tag library.
> >
> > Sorry, I don't know the answer for Struts 1.x
> >
> > Asad Habib wrote:
> >> Hello Jeromy. What tag library are you using for this?
> >>
> >> - Asad
> >>
> >>
> >>
> >> On Feb 19, 2008 11:19 PM, Jeromy Evans
> >> <je...@blueskyminds.com.au> wrote:
> >>
> >>> You may be able to do it with s:property, disabling escaping of the
> >>> html:
> >>>
> >>> <s:property value="getText('some.key')" escape="false"/>
> >>>
> >>>
> >>> Asad Habib wrote:
> >>>
> >>>> Hello. How do I represent the following in a message resources file?
> >>>> Representing a string literal is easy but the following string
> >>>> contains a link. Can this even be done? I have used variables with the
> >>>> validator before but there is no validator involved in this case.
> >>>> Thank you.
> >>>>
> >>>> Please <a href="login.jsp">click here</a> to sign in.
> >>>>
> >>>>
> >>>> - Asad
> >>>>
> >>>> ---------------------------------------------------------------------
> >>>> 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
> >>>
> >>>
> >>>
> >>
> >> ---------------------------------------------------------------------
> >> 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
> >
> >
>
>
> ---------------------------------------------------------------------
> 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: Using Variables with Messages in Struts
Posted by Nuwan Chandrasoma <my...@gmail.com>.
Hi,
why dont you try the <bean:write> tag with filter attribute as false.
Thanks,
Nuwan
Jeromy Evans wrote:
> Oh, sorry, I assumed you were using Struts 2. That's a feature of the
> default tag library.
>
> Sorry, I don't know the answer for Struts 1.x
>
> Asad Habib wrote:
>> Hello Jeromy. What tag library are you using for this?
>>
>> - Asad
>>
>>
>>
>> On Feb 19, 2008 11:19 PM, Jeromy Evans
>> <je...@blueskyminds.com.au> wrote:
>>
>>> You may be able to do it with s:property, disabling escaping of the
>>> html:
>>>
>>> <s:property value="getText('some.key')" escape="false"/>
>>>
>>>
>>> Asad Habib wrote:
>>>
>>>> Hello. How do I represent the following in a message resources file?
>>>> Representing a string literal is easy but the following string
>>>> contains a link. Can this even be done? I have used variables with the
>>>> validator before but there is no validator involved in this case.
>>>> Thank you.
>>>>
>>>> Please <a href="login.jsp">click here</a> to sign in.
>>>>
>>>>
>>>> - Asad
>>>>
>>>> ---------------------------------------------------------------------
>>>> 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
>>>
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Using Variables with Messages in Struts
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
Oh, sorry, I assumed you were using Struts 2. That's a feature of the
default tag library.
Sorry, I don't know the answer for Struts 1.x
Asad Habib wrote:
> Hello Jeromy. What tag library are you using for this?
>
> - Asad
>
>
>
> On Feb 19, 2008 11:19 PM, Jeromy Evans <je...@blueskyminds.com.au> wrote:
>
>> You may be able to do it with s:property, disabling escaping of the html:
>>
>> <s:property value="getText('some.key')" escape="false"/>
>>
>>
>> Asad Habib wrote:
>>
>>> Hello. How do I represent the following in a message resources file?
>>> Representing a string literal is easy but the following string
>>> contains a link. Can this even be done? I have used variables with the
>>> validator before but there is no validator involved in this case.
>>> Thank you.
>>>
>>> Please <a href="login.jsp">click here</a> to sign in.
>>>
>>>
>>> - Asad
>>>
>>> ---------------------------------------------------------------------
>>> 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
>>
>>
>>
>
> ---------------------------------------------------------------------
> 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: Using Variables with Messages in Struts
Posted by Asad Habib <as...@gmail.com>.
Hello Jeromy. What tag library are you using for this?
- Asad
On Feb 19, 2008 11:19 PM, Jeromy Evans <je...@blueskyminds.com.au> wrote:
> You may be able to do it with s:property, disabling escaping of the html:
>
> <s:property value="getText('some.key')" escape="false"/>
>
>
> Asad Habib wrote:
> > Hello. How do I represent the following in a message resources file?
> > Representing a string literal is easy but the following string
> > contains a link. Can this even be done? I have used variables with the
> > validator before but there is no validator involved in this case.
> > Thank you.
> >
> > Please <a href="login.jsp">click here</a> to sign in.
> >
> >
> > - Asad
> >
> > ---------------------------------------------------------------------
> > 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
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: Using Variables with Messages in Struts
Posted by Jeromy Evans <je...@blueskyminds.com.au>.
You may be able to do it with s:property, disabling escaping of the html:
<s:property value="getText('some.key')" escape="false"/>
Asad Habib wrote:
> Hello. How do I represent the following in a message resources file?
> Representing a string literal is easy but the following string
> contains a link. Can this even be done? I have used variables with the
> validator before but there is no validator involved in this case.
> Thank you.
>
> Please <a href="login.jsp">click here</a> to sign in.
>
>
> - Asad
>
> ---------------------------------------------------------------------
> 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