Default stateless theme switcher
Multi-themable web applications require a theme switcher component. The default PrimeFaces' theme switcher is a component, which enables switching themes on the fly without a round-trip to the server. We speak about a stateless theme switcher because the current selected theme is only known on the client side.
In this recipe, we will show the usage of such a stateless theme switcher.
How to do it...
The theme switcher usage is very similar to the usage of p:selectOneMenu
. The component is represented by the p:themeSwitcher
tag and accepts f:selectItem
or f:selectItems
.
<p:themeSwitcher style="width:165px" effect="fade"> <f:selectItem itemLabel="Choose Theme" itemValue=""/> <f:selectItems value="#{userSettingsController.themes}"/> </p:themeSwitcher>
Themes are prepared in a managed bean UserSettingsController
.
@ManagedBean @SessionScoped public class UserSettingsController implements Serializable { public Map<String, String...