widget和Decorator装修器的使用
来源:互联网 发布:js函数call 编辑:程序博客网 时间:2024/04/28 16:50
ofbiz中的Widget小窗口和Decorator装修器是ofbizView层的技术,使用widget我们可以将很多零散的页面部分拼合成一张页面。
这样,每张页面都有的公共部分。因此我们只创建一次,再创建新页面时,我们只创建不同的部分即可。
Widget是用xml文件表示的,存放的位置是..\widget\XxxxScreen.xml。
零散的页面通常放在相应的app\webapp\app\下和app\webapp\app\includes\下。
(app\webapp\app\存放的是不同的页面部分,app\webapp\app\includes\下存放的是相同的页面部分)
Widget示例代码:
screen name="news" section widgets platform-specifichtmlhtml-template location="component://hello2/webapp/hello2/includes/header.ftl"//html/platform-specific platform-specifichtmlhtml-template location="component://hello2/webapp/hello2/news.ftl"//html/platform-specific platform-specifichtmlhtml-template location="component://hello2/webapp/hello2/includes/footer.ftl"//html/platform-specific /widgets /section /screen代码中我们可以看到news页面由三部分组成:header.ftl,main.ftl,footer.ftl。这三部分的路径都在代码中明确给出,这样的话当用户请求页面news时,ofbiz就会根据代码中给出的路径找到页面的不同部分,将它们组合起来再返回一张完整的页面的用户。
因此,Decorator装修器可以帮我们解决这个问题!Decorator是一个页面模板,该模板也是一个screen元素,模板名通常叫CommonDecorator,和widget定义在相同的XML文件中。当模板定义后每一个页面的定义就不用像上面这样将所有的部分都列出来了,可以只用列出和其它页面不同的部分。
Decorator示例代码:
screenname="CommonDecorator" section widgets platform-specifichtmlhtml-template location="component://hello2/webapp/hello2/includes/header.ftl"//html/platform-specific decorator-section-include name="body"/ platform-specifichtmlhtml-template location="component://hello2/webapp/hello2/includes/footer.ftl"//html/platform-specific /widgets /section /screen screen name="news" section widgets decorator-screenname="CommonDecorator" decorator-section name="body" platform-specifichtmlhtml-templatelocation="component://hello2/webapp/hello2/news.ftl"//html/platform-specific /decorator-section /decorator-screen /widgets /section /screen
代码中,页面news的代码就要比一开始少了很多,原因就是使用了模板CommonDecorator。
模板页面和普通页面是一样的XML元素,但在其中有一句话不同:decorator-section-includename="body"/,该句话所在的位置就是使用了该模板的页面需要添加自己内容的位置。
在示例代码中,模板定义了HTML头和脚,使用该模板需要添加的部分就是主体部分。
模板中可以添加内容的位置用decorator-section-includename="body"/标识,应该可以有多个位置可以。
0 0
- widget和Decorator装修器的使用
- ofbiz学习日记--Widget小窗口和Decorator装修器的使用(利昂原创)
- 浅谈装修模式decorator
- 装修模式decorator
- [Struts 2] decorator(sitemesh)修饰器的配置和使用
- widget,MainWindow和Dialog的选择使用
- widget,MainWindow和Dialog的选择使用
- widget,MainWindow和Dialog的选择使用
- widget,MainWindow和Dialog的选择使用
- widget,MainWindow和Dialog的选择使用
- widget,MainWindow和Dialog的选择使用
- Python:decorator的使用
- decorator的使用
- Python的decorator使用
- Python的walk和Decorator使用一例
- App Widget的使用
- Widget的使用
- Tizen widget的使用
- 安装apk到AVD
- 自定义导航转场动画以及更多
- Android HttpUrlConnection 发送网络请求步骤总结
- Android中TextView中部分文字有不同颜色的实现
- php面向对象一些笔记
- widget和Decorator装修器的使用
- Zookeeper学习9_zookeeper项目使用几点小结
- ORACLE SQL性能优化系列 (三)
- JavaEE_JSP_JSTL标签 参考手册
- cocos2d-x开发学习笔记(一)
- Linux中vi编辑器
- 调试 make
- 自定义粘性View (备忘)
- ORACLE SQL性能优化系列 (二)