This content has been marked as final.
Show 1 reply
-
1. Re: Dynamic Label using properties file
niox.nikospara.yahoo.com Jun 24, 2009 3:35 PM (in response to tekchandp)EL does not support String concatenation, so I create a Facelets library with an EL function for string concatenation and use it like:
<ui:composition ... xmlns:xx="http://www.my-own-url.com/jsf/facelets"> <s:selectItems ... label="#{messages[xx:strcat('person.state.',sp)]}" .../> </ui:composition>
To do this you need a file called eg xx.taglib.xml like:
<?xml version="1.0"?> <!DOCTYPE facelet-taglib PUBLIC "-//Sun Microsystems, Inc.//DTD Facelet Taglib 1.0//EN" "https://facelets.dev.java.net/source/browse/*checkout*/facelets/src/etc/facelet-taglib_1_0.dtd" > <facelet-taglib> <namespace>http://www.my-own-url.com/jsf/facelets</namespace> <function> <function-name>strcat</function-name> <function-class>xx.Util</function-class> <function-signature>java.lang.String strcat(java.lang.String,java.lang.String)</function-signature> </function> </facelet-taglib>
Then the class xx.Util:
public class Util { public static String strcat(String s1, String s2) { return s1+s2; } }
And finally declare the Facelets library in web.xml:
<context-param> <param-name>facelets.LIBRARIES</param-name> <param-value>/WEB-INF/xx.taglib.xml</param-value> </context-param>