Though the themeSwitcher list appears and the theme is switching, the graphics aren't appearing as I do not have them. (Where might they be found, btw?)
However, I created a getImage method on the theme object to return the byte stream for a place holder image (in the hopes of figuring out this layout issue):
Code: Select all
public StreamedContent getImage() {
InputStream stream = this.getClass().getResourceAsStream("/resources/images/themes/man-icon.png");
return new DefaultStreamedContent(stream, "image/png");
}
Code: Select all
<p:themeSwitcher id="ddlTheme" var="theme" style="width:200px;" effect="fade"
value="#{themeSwitcher.currentTheme}">
<p:ajax listener="#{themeSwitcher.saveTheme}" />
<f:selectItem
itemLabel="#{messages.getString('application.lbl.theme.select')}"
itemValue="" />
<f:selectItems value="#{themeSwitcher.themes}" var="t"
itemLabel="#{t.displayName}" itemValue="#{t.name}" />
<p:column><p:graphicImage value="#{theme.image}" /></p:column>
<p:column>
<h:outputText styleClass="ui-theme ui-theme-#{theme.name}"
style="display-block" />
</p:column>
</p:themeSwitcher>
I'm using CDI with PF.
Code: Select all
@Named
@SessionScoped
public class ThemeSwitcher implements Serializable {
private static final long serialVersionUID = -2874924104373802376L;
private static final String UI = "UI";
private static final String THEME_NAME = "theme-name";
private static final String DEFAULT_THEME = "bluesky";
private List<Theme> themes;
@Inject
private CurrentUserHolder currentUserHolder;
@Inject
private ThemeService service;
private String currentTheme;
@PostConstruct
public void init() {
themes = service.getThemes();
currentTheme = DEFAULT_THEME;
}
public List<Theme> getThemes() {
return themes;
}
public void setService(ThemeService service) {
this.service = service;
}
public void saveTheme() {
if ( currentUserHolder != null && !StringUtils.isEmpty(currentTheme) )
currentUserHolder.savePreference(UI, THEME_NAME, currentTheme);
}
public String getCurrentTheme() {
return currentTheme;
}
public void setCurrentTheme(String currentTheme) {
this.currentTheme = currentTheme;
}
}