chenge theme based on user prifile

UI Components for JSF
Post Reply
banto.78
Posts: 38
Joined: 26 Dec 2013, 18:45

18 Jul 2014, 13:06

Hi al,

i am following the on-line advices but i am not get along.

I want to change the theme based on the user logged in.

As try i added the theme glass-x.jar and changed the web.xml like this:

Code: Select all

	<context-param>
		<param-name>primefaces.THEME</param-name>
		<param-value>glass-x</param-value>
	</context-param>
and it works.

However i would like to store the theme in the DB. So I have an UserBean (SessionScope) with relative theme attribute and now is:

Code: Select all

	<context-param>
		<param-name>primefaces.THEME</param-name>
		<param-value>#{userBean.theme}</param-value>
	</context-param>
Of course when i load the application no user is logged-in. So i though the theme value default to 'aristo' but i get the following error:

Code: Select all

Caused by: javax.faces.FacesException: Error loading theme, cannot find "theme.css" resource of "primefaces-" library
can you pls tell me where i am worng?

thanks lot!
Tomcat/7.0.35, primefaces-4.0.jar
atmosphere-runtime-2.1.0-RC2.jar,
jsf-api-2.2.0-m05.jar, jsf-impl-2.2.0-m05.jar
Eclipse 3.8 ¦ FF

banto.78
Posts: 38
Joined: 26 Dec 2013, 18:45

18 Jul 2014, 22:15

i think i found somethign following the code on-line.

However still i am not able to set the theme out of this code:

Code: Select all

<p:themeSwitcher value="#{guestPreferences.theme}" style="width:150px" effect="fade">
						<f:selectItem itemLabel="--Choose Theme--" itemValue=""/>
						<f:selectItems value="#{themeSwitcherBean.themes}"/>
						<p:ajax listener="#{themeSwitcherBean.saveTheme}"/>
				</p:themeSwitcher> 
How can the selectItem in this xhtml can call the set on the ThemeSwtcherBean?

Code: Select all

public void setTheme(String theme) {
        this.theme = theme;
    }
I mean this is not SelectOneMenu component :geek: so the result is that once the listener is called the "theme" on the backing bean is NULL!!

Please help. tks
Tomcat/7.0.35, primefaces-4.0.jar
atmosphere-runtime-2.1.0-RC2.jar,
jsf-api-2.2.0-m05.jar, jsf-impl-2.2.0-m05.jar
Eclipse 3.8 ¦ FF

User avatar
andyba
Expert Member
Posts: 2473
Joined: 31 Mar 2011, 16:27
Location: Steinfeld, near Bremen/Osnabrück, DE
Contact:

21 Jul 2014, 09:54

If you want to ensure that the dynamic theme has a default set the value of the theme property in your bean to "aristo".
PF 4.x (Elite versions), PF 5, Pf 5.1, PF 6.0
Glassfish 4.1, Mojarra 2.x, Java 8, Payara 4.1.1.
If you haven't read the forum rules read them now

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 21 guests