Access ResourceBundle keys that contain dots?

My JSF2 application is fully internationalized using the ResourceBundle.

Now I have a lot of Javascript code in which there are some warnings and stuff. There I would like to access my ResourceBundle. I could successfully access the simple ResourceBundle keys as follows:

alert("#{bundle.message_email_sent}");

Unfortunately, my convention for keys in my package is to use dots . as separators for my keys, for example message.email.sent=E-Mails sent.. But when I do

alert("#{bundle.message.email.sent}");

JSF is trying to access "email" as a function on the line returned by bundle.message. How can I tell EL-resolver to use the entire "message.email.sent" as a key?

I also tried things like

alert("#{bundle[\'message.email.sent\']}");

. ?

+3
1

, "" , EL, , , JS . EL Java/JSF, JS.

alert("#{bundle['message.email.sent']}");
+8

Source: https://habr.com/ru/post/1757709/


All Articles