1
votes

I need to make the theme dynamic by the different users, currently, I find the guide in http://www.developer.am/primefaces/?page=Applying%20a%20Theme

It says: In case you’d like to make the theme dynamic, define an EL expression as the param value.

<context-param>
    <param-name>primefaces.THEME</param-name>
    <param-value>#{loggedInUser.preferences.theme}</param-value>
</context-param>

In my understanding, the theme will be changed by the different users, right? Even I change the theme in preferences for the user, I have no need to restart the middleware, the theme will be changed at once, right?

Please guide me, thanks in advance.

2

2 Answers

5
votes

You seem to be expecting that the EL expression is evaluated at the moment the web.xml is parsed. This is not true. Instead, all PrimeFaces gets from the web.xml init param is a String representing an EL expression like so:

String themeExpression = "#{loggedInUser.preferences.theme}";

Then, PrimeFaces is programmatically evaluating it on every HTTP request like follows in order to get the actual value:

String theme = context.getApplication().evaluateExpressionGet(context, themeExpression, String.class);

In effects, it's request scoped and not application scoped as you seemed to expect. The evaluated property can in turn however just be a property of a session scoped bean.

1
votes

Yes. You just need a bean that will return the users's theme name as a string.