Is there a way to have Expression Language (EL) expressions included JavaScript files be evaluated by JSF?
I was hoping that Seam might have a way around this, but no luck so far. All I want is to be able to use localized messages in my JavaScript functions which are shared across pages.
Five ways:
Declare it as global variable in the parent JSF page.
Or, if it’s in JSON format already.
Put the whole
<script>in a XHTML file and useui:includeto include it.Pass
*.jsthrough theJspServlet(only if it’s enough to evaluate only the${}expressions). E.g. inweb.xml(the<servlet-name>ofJspServletcan be found inweb.xmlof the servletcontainer in question, it’s usuallyjsp).Make use of “good old” JSP with a modified content type. Rename
script.jstoscript.jspand add the following line to top of JSP (only if it’s enough to evaluate only the${}expressions):Let JS obtain the data ajaxically during load. Here’s a jQuery targeted example.