Can I use EL expression inside web.xml ?
Like this
Web.xml
<context-param>
<param-name>primefaces.DIR</param-name>
<param-value>#{userUtilityBacking.direction}</param-value>
</context-param>
and my JSF bean like this
JSF bean
@ManagedBean(name="userUtilityBacking")
@SessionScoped
public class UserUtilityBacking implements Serializable {
private static final long serialVersionUID = 1L;
private String direction ;
// and public setters and getter
Will it work ?
Can I use EL expression inside web.xml ?
Not exactly that. By default, the servletcontainer doesn't EL-evaluate the context parameters when the web.xml
is been parsed during application startup. However, build tools like Ant and Maven and some servletcontainers like JBoss (after setting a specific configuration setting) support using ${...}
syntax similar to EL to inline environment variables and/or VM arguments by their name in several deployment descriptor XML files such as web.xml
, ejb-jar.xml
and persistence.xml
. Note: that are thus not those variables which you've declared in JSF EL scope, such as managed bean.
Will it work ?
It will only work if PrimeFaces gets the static value "#{userUtilityBacking.direction}"
as String
and then programmatically EL-evaluates it in the current EL context using for example Application#evaluateExpressionGet()
. But, based on the PrimeFaces 3.5 source code, it is not doing that anywhere. It look like they implemented it for 4.x only.
In your particular case, you'd better just specify the direction directly on <html>
element to apply it document-wide and/or in dir
attribute of an arbitrary HTML or JSF component.
<html dir="#{userUtilityBacking.direction}">