myfaces-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "R. Müller" <>
Subject string concatenation & EL expressions
Date Mon, 12 Dec 2005 12:46:37 GMT
hi group,

a bit OT, but nevertheless worth asking this group, since there are much 
people here, who're dealing with this each day.

its often the case, that you ask a property-map for internationalization 
(i.e. the ResourceBundle) your pages.

sometimes you do it in a dynamic way :

imagine there is boolean property of a backing bean :


your want to internationalize the output by asking the resource-bundle :

<h:outputText value="#{myBundle[mybean.on]}"/>

so far this is working, but no nice solution, since your property-file 
has to look like this :

true = on
false = off

i want a property-file like this

myDevice.state.true = on
myDevice.state.false = off

ok, the first thought is probably :

<h:outputText value="#{myBundle['myDevice.state.'mybean.on]}"/>

but this doesn't work at all. there is a kind of concatenating-operator 

the only workaround, i 've found is using JSTL's <c:set .../> before to 
set up a single value as the map-key into requestScope.

<c:set var="key" value="myDevice.state.#{mybean.on}" scope="request"/>
<h:outputText value="#{myBundle[requestScope['key']]}"/>

works, but not so nice. sometimes its no good idea to mix up JSF and 
JSTL and you'll get trouble with this.

any better solution ?

regards ronald

View raw message