【问题标题】:how keeping primefaces theme for all pages and session with spring security如何使用 Spring Security 为所有页面和会话保持 primefaces 主题
【发布时间】:2020-07-23 20:31:37
【问题描述】:

我使用 maven 和 netbeans 8.2。在 maven pom 中我有:

org.primefaces/primefaces/7.0
org.primefaces.themes/all-themes/1.0.10

在我的 Login.xhtml 页面中,我使用 themeSwitcher 来选择用户可以在整个会话期间保留的主题,而无需将主题保留在数据库表中,我受到以下 primefaces 展示的启发:here

只有在登录后,当我为我的索引页面中的所有页面更改主题时,更改才会生效。在我的 HttpSecurity 配置中,我放了:

.formLogin().loginPage("/login.xhtml").permitAll()

我是 jsf 和 java 的新手。

提前感谢您的帮助

【问题讨论】:

  • 我有似曾相识的感觉...
  • 对!我犯了错误,我删除了我之前的帖子:-)

标签: primefaces themes jsf-2.2


【解决方案1】:

只有在用户登录并放置后才能工作:

web.xml

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

并在

中初始化变量主题
   @PostConstruct
public void init() {
    theme="omega";
    themes = service.getThemes();
}
...
public String getTheme() {
    return theme;
}

public void setTheme(String theme) {
    this.theme = theme;
}

public void saveTheme(AjaxBehaviorEvent ajax) {   
    setTheme((String) ((ThemeSwitcher)ajax.getSource()).getValue());
}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2019-09-23
    • 2012-02-19
    • 1970-01-01
    • 2015-01-26
    • 1970-01-01
    • 2013-04-25
    • 2012-07-06
    相关资源
    最近更新 更多