Java Reference
In-Depth Information
If we change the value of the contracts attribute of <f:view> to dark , we can see
the dark theme in action.
Of course, hardcoding the resource library contract like we did in our example
doesn't make a whole lot of sense. To dynamically change the theme, we need to
set the value of the contracts attribute of <f:view> to a value binding expression
pointing to a named bean property.
In our project, we will add a ThemeSelector named bean to hold the theme selected
by the user:
package com.ensode.jsf.resourcelibrarycontracts.namedbeans;
import javax.enterprise.context.RequestScoped;
import javax.inject.Named;
@Named
@RequestScoped
public class ThemeSelector {
private String themeName = "normal";
public String getThemeName() {
return themeName;
}
public void setThemeName(String themeName) {
this.themeName = themeName;
}
}
 
Search WWH ::




Custom Search