appfuse 样式主题
appfuse中web.xml的css样式配置说明:
<!-- Define the default CSS Theme --> <context-param> <param-name>theme</param-name> <param-value>simplicity</param-value> </context-param>
该段用于页面整体风格,theme的值对应相应样式文件夹,appfuse对这个参数的使用如下:
- 在/myapp/src/web/org/appfuse/webapp/listener/StartupListener.java文件中将theme值放入ServletContext
- 在/myapp/src/web/org/appfuse/webapp/filter/LocaleFilter.java文件中将request中的theme值保存到ServletContext
- 页面根据theme值加载css文件
StartupListener.java关键代码
ServletContext context = event.getServletContext(); // Orion starts Servlets before Listeners, so check if the config // object already exists Map config = (HashMap) context.getAttribute(Constants.CONFIG); if (config == null) { config = new HashMap(); } if (context.getInitParameter("theme") != null) { config.put("theme", context.getInitParameter("theme")); }
LocaleFilter.java
String theme = request.getParameter("theme"); if (theme != null && request.isUserInRole(Constants.ADMIN_ROLE)) { Map config = (Map) getServletContext().getAttribute(Constants.CONFIG); config.put("theme", theme); }
页面根据theme值加载css文件
<link rel="stylesheet" type="text/css" media="all" href="<c:url value='/styles/${appConfig["theme"]}/theme.css'/>" /> <link rel="stylesheet" type="text/css" media="print" href="<c:url value='/styles/${appConfig["theme"]}/print.css'/>" />
相关推荐
gretaguo 2013-08-26
yygy0 2013-04-11
gretaguo 2013-04-10
zhongminli 2013-04-10
chenyingSunny 2013-04-08
gretaguo 2012-11-06
changNet 2012-07-20
gretaguo 2012-07-20
owilson 2012-04-18
changNet 2012-04-18
jeson00 2012-03-06
yygy0 2012-02-26
xiaoguanmeizi 2011-10-30
chenyingSunny 2011-10-10
yygy0 2011-08-31
yygy0 2011-08-08
cgy 2011-05-06