struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Damm, Gary" <ga...@qualcomm.com>
Subject RE: Using internationalised messages as custom tag parameters
Date Tue, 18 Feb 2003 17:37:53 GMT
Here is another way to do it:

Define the I18N string:
<bean:define id="thId"><bean:message key="label.id"/></bean:define>

Access it with a scriplet in another tag:
<display:column title="<%=thId%>" property="detailLink" sort="true" />

Still would be nicer for the later tag to support I18N but nothings
perfect.

Gary

-----Original Message-----
From: Alan P Sexton [mailto:A.P.Sexton@cs.bham.ac.uk] 
Sent: Monday, January 20, 2003 2:12 AM
To: struts-user@jakarta.apache.org
Subject: RE: Using internationalised messages as custom tag parameters


I don't understand: that is pretty much exactly what I am doing as
described in my original message and it works correctly. I was just
hoping for an alternative that could be done with tags so that I don't
need to use scriptlets: I am just about okay with using simple
expressions in scriptlets, but declaring variables I find too messy.

So the original question stands: how can this be done with less
scriptlet use short of hacking the display tag library, and every other
tag library where I similarly want to use internationalised message
strings?

Alan

Marco Tedone writes:
 > Have you tried with the following?
 > 
 > MessageResources resources =
 > (MessageResources)request.getAttribute(xxx.MESSAGES_KEY);
 > 
 > Then the resources.getMessage("xxx") shall return you the value.
 > 
 > Hope it will works :-)
 > 
 > -----Original Message-----
 > From: Alan P Sexton [mailto:A.P.Sexton@cs.bham.ac.uk] 
 > Sent: Sunday, January 19, 2003 11:34 PM
 > To: struts-user@jakarta.apache.org
 > Subject: Using internationalised messages as custom tag parameters
 > 
 > 
 > 
 > When using custom tags, sometimes I want to pass an internationalised
string
 > as an attribute value: e.g. using the display:column tag inside
 > display:table, I want to specify the column title using the message
resource
 > key and not a constant string.
 > 
 > Currently I have it working using the very ugly code (cut down and
 > simplified):
 > 
 > ...
 > <% org.apache.struts.util.PropertyMessageResources msgs = 
 >  
 >
((org.apache.struts.util.PropertyMessageResources)request.getAttribute(o
rg.apache.struts.Globals.MESSAGES_KEY) ; %>
 > 
 > ...
 > <display:table name="list">
 >  <display:column property="z1" title="<%=
msgs.getMessage(Constants.COL_HEADING_Z1) %>" />
 >  <display:column property="z2" title="<%=
msgs.getMessage(Constants.COL_HEADING_Z2) %>" />
 >  <display:column property="z3" title="<%=
msgs.getMessage(Constants.COL_HEADING_Z3) %>" />
 > </display:table>
 > 
 > Ideally I would like to be able to set this attribute using the
bean:message
 > tag, but I don't see any way to do so.
 > 
 > I would also like to be able to easily apply text filtering for html
 > sensitive characters as per bean:write
 > 
 > Is there a cleaner, neater way to do all this?
 > 
 > Alan Sexton
 > 

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


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


Mime
View raw message