Search code examples
arraysjsfelproperties-file

jsf access element from array in properties file


How do I access an element from an array in a properties file?

testKey = word1,word2,word3

Something like this is not working (assume properties file is mapped to "msg"

#{msg.testKey[0]} <- to access first element

Solution

  • It's a String, not a String[]. You've got to split it on the comma first by fn:split() to get a String[] out of it so that you can access the items by an index.

    #{fn:split(msg.testKey, ',')[0]}