Reputation: 21218
My JSF2 application is fully internationalized, using a ResourceBundle.
Now i have a lot of Javascript-code, which does some alerts and stuff. There i would like to access my ResourceBundle. I could successfully access simple ResourceBundle keys like this:
alert("#{bundle.message_email_sent}");
Unfortunately, my convention for keys in my bundle is to use dots . as seperators for my keys, for example message.email.sent=E-Mails sent.
. But when i do
alert("#{bundle.message.email.sent}");
JSF tries to access "email" like a function on the string returned by bundle.message. How can i tell the EL-resolver to use the whole "message.email.sent" as the key?
I also tried stuff like
alert("#{bundle[\'message.email.sent\']}");
Which also results in errors. Any suggestions?
Upvotes: 5
Views: 2469
Reputation: 1108557
You indeed need to use the brace notation, when the 'key' contains characters that have a meaning in EL, but you don't need to escape the singlequotes, regardless of whatever JS syntax highlighter is telling you otherwise. EL runs when Java/JSF runs, not when JS runs.
alert("#{bundle['message.email.sent']}");
Upvotes: 9