webwork 2.2.2中提供了几个theme,包括simple,xhtml以及新的ajax,css_xhtml等等.
每个控件都可以指定theme,那么theme是什么查找顺序哪?都由什么因素控制哪?
让我们来看UIBean中的一段代码:
|
public String getTheme() { String theme = null;
if (this.theme != null) { theme = findString(this.theme); }
if ( theme == null || theme.equals("") ) { Form form = (Form) findAncestor(Form.class); if (form != null) { theme = form.getTheme(); } }
// If theme set is not explicitly given, // try to find attribute which states the theme set to use if ((theme == null) || (theme.equals(""))) { theme = (String) stack.findValue("#attr.theme"); }
// Default theme set if ((theme == null) || (theme.equals(""))) { theme = Configuration.getString(WebWorkConstants.WEBWORK_UI_THEME); }
return theme; }
|
可以看到,顺序是这样的:
- 首先查找控件本身的theme,也就是说控件本身可以设定theme
- 如果没有找到,则查找此控件所在的form的theme,如果找到了,就使用form的theme设定
- 如果还没有找到,则在value stack里查找属性theme. 也就是说你可以编程控制theme设定
- 如果最后还没有找到,则到配置文件里寻找,默认的是xhtml,用户可以在webwork.properties里面修改配置
这样你就可以在各个环节进行设置,达到自己的目的.
其中attr的说明参考 http://wiki.opensymphony.com/display/WW/Accessing+application%2C+session%2C+request+objects 以及 http://wiki.opensymphony.com/display/WW/What+are+the+default+variables+in+the+value+stack
attr: 会依次扫描 request, session 和 application attributes 设置.
|
除经特别注明外,本文章版权归JScud Develop团队或其作者所有.
署名,非商业用途,保持一致. scud(飞云小侠) JScud Develop
|
|