如何在Primefaces中保存主题 [英] How to save theme in Primefaces

查看:117
本文介绍了如何在Primefaces中保存主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想使用Primefaces ThemeSwitcher .我对重新加载Web应用程序时如何保存所选主题感兴趣.例如,如何从数据库中将主题名称设置为变量?

I want to use Primefaces ThemeSwitcher. I'm interested how I can save the selected theme when I reload the web application. For example how I can set the theme name as variable from database?

推荐答案

您将不需要ThemeSwitcher来实现所需的持久性.

You won't be needing the ThemeSwitcher to effect the kind of persistence you're looking for.

只需在 ServletContextListener ,然后将值存储在servlet上下文中,可能会覆盖您在web.xml中设置的任何内容

Simply perform the database lookup for the theme in a ServletContextListener and then store the value in the servlet context, possibly overriding whatever you've set in the web.xml

   public Class MyContextListener implements ServletContextListener{

     public void contextInitialized(ServletContextEvent sce){

      String selectedTheme = myThemeDAO.getConfiguredTheme();

      sce.getServletContext().setInitParameter("primefaces.THEME",selectedTheme);

     }


   }

这篇关于如何在Primefaces中保存主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆