appfuse web.xml文件解释说明--样式主题

appfuse中web.xml的css样式配置说明:

1     <!-- Define the default CSS Theme -->
2     <context-param>
3         <param-name>theme</param-name>
4         <param-value>simplicity</param-value>
5     </context-param>

该段用于页面整体风格,appfuse对这个参数的使用如下:

  • 在/myapp/src/web/org/appfuse/webapp/listener/StartupListener.java文件中将theme值放入ServletContext
  • 在/myapp/src/web/org/appfuse/webapp/filter/LocaleFilter.java文件中将request中的theme值保存到ServletContext
 1         ServletContext context = event.getServletContext();
 2 
 3         // Orion starts Servlets before Listeners, so check if the config
 4         // object already exists
 5         Map config = (HashMap) context.getAttribute(Constants.CONFIG);
 6 
 7         if (config == null) {
 8             config = new HashMap();
 9         }
10         
11         if (context.getInitParameter("theme") != null) {
12             config.put("theme", context.getInitParameter("theme"));
13         }
View Code
1         String theme = request.getParameter("theme");
2         if (theme != null && request.isUserInRole(Constants.ADMIN_ROLE)) {
3             Map config = (Map) getServletContext().getAttribute(Constants.CONFIG);
4             config.put("theme", theme);
5         }
View Code
  • 页面根据theme值加载css文件
1         <link rel="stylesheet" type="text/css" media="all" href="<c:url value='/styles/${appConfig["theme"]}/theme.css'/>" />
2         <link rel="stylesheet" type="text/css" media="print" href="<c:url value='/styles/${appConfig["theme"]}/print.css'/>" />
View Code

 

posted @ 2013-08-23 15:39  亿度思考  阅读(220)  评论(0)    收藏  举报