Chapter 3: Screen Widgets
来源:互联网 发布:快速求斗牛的算法 编辑:程序博客网 时间:2024/05/16 11:38
Conditional Widget
<screen name="ConditionalScreen"> <section> <condition> <if-compare field-name="parameters.show" operator="equals" value="widgets"></if-compare> </condition> <actions> <set field="blah" value="blih"></set> </actions> <widgets> <label text="Condition passed. Showing widgets element. Blah is: ${blah}"></label> </widgets> <fail-widgets> <label text="Condition failed! Showing fail-widgets element. Blah is: ${blah}"></label> </fail-widgets> </section> </screen>
其中,actions和widgets是condition为true时候会运作的内容,fail-widgets是为false时候运行的内容。这类似于if-else的结构。
关于<if-condition>
有如下的条件:
4种logical operators:<and>, <xor>, <or>, <not>
3种permissions-related checks: <if-service-permission> , <if-has-permission>, <if-entity-permission>
5种comparators:<if-validate-method>, <if-compare>, <if-compare-field> , <if-regexp>, <if-empty>
例:
<condition><not><if-empty field-name="parameters.submit"/></not></condition>
关于<actions>
有如下的action可以使用:
5种data retrieval操作:
<actions> <entity-one entity-name="Planet" value-name="planet"> <field-map field-name="planetId" env-name="mechMap.postalAddress.planet"/> </entity-one> <entity-condition entity-name="Planet" filter-by-date="true" list-name="planets"> <order-by field-name="planetName"/> </entity-condition> </actions>
- <entity-one> - 将会遍历Planet这个Entity,找到planetId为mechMap.postalAddress.planet的record,把他存在变量planet中
- <entity-condition> - 将Entity Planet中的所有内容pull到list planets中
- <filter-by-date> - specifies that the query must filter out those records that are not active now
- <order-by> - pull的record安装planetName升序排序,如果要降序,就field-name="planetName DESC"
- <entity-and>,
- <get-related-one>,
- <get-related>
2种引入business logic的操作:
- <script> - 使用脚本,如ftl
- <service>
3种设置值的操作:
<property-map>
如,在CommonScreen.xml中有这么一段:
<actions> <!-- base/top/specific map first, then more common map added for shared labels --> <property-map resource="LearningUiLabels" map-name="uiLabelMap" global="true"/><property-map resource="CommonUiLabels" map-name="uiLabelMap" global="true"/>这里的作用实际上是声明了一个全局都可以使用map,用config目录下的LearningUiLabels.xml中的property来初始化,使用这个map的方法如下
<set field="layoutSettings.companyName" from-field="uiLabelMap.LearningCompanyName" global="true"/> <set field="layoutSettings.companySubtitle" from-field="uiLabelMap.LearningCompanySubtitle" global="true"/>
- <property-to-field>
- <set> - 设置一个参数的值
关于<widget>
如下15种内容可以使用:
- <container> - 自我感觉就是显示的时候起到换行的作用
- <image>
- <link>
- <label>, (以后补充)
关于<fail-widgets>
类似于<widget>,只不过只有在condition为false的时候才会运行里面的代码
关于条件参数的传入
我们有着这样的一行代码
<if-compare field-name="parameters.show" operator="equals" value="widgets"></if-compare>
那么,这个show的值如何传入呢?
通常,我们在URL请求中使用“?”来表示开始传入参数,如:
http://localhost:8080/learning/control/SomeRequest?paramOne=valueOne
如果有多个参数,就用“&”,如:
http://localhost:8080/learning/control/SomeRequest?paramOne=valueOne¶mTwo=valueTwo
Screen Widget Context and VariablesEach screen widget's actions (in <actions> sub-element) operate within their own private context. In that context, all variables are private to that context
有10种对象可以在context中使用:
- screen - 使用FreeMarker temple载入sub-screen
- globalContext - 被top level screen本身和它的嵌套窗口共享
- nullField - 用于数据库空值的判断
- availableLocales和locale - 用于不同地区语言的选择,新版的OFBiz已经不怎么用的,软件如果不跨国家使用,我觉得这个我们也用不上
- delegator - 用于与数据库的交互
- dispatcher - 用于调用OFBiz的service
- security - 提供一系列安全操作的工具
- userLogin - 顾名思义,常与security一起使用
- parameters - 一个request parameters的map,可以得到各个request parameter的值
- Chapter 3: Screen Widgets
- Chapter 5: Other View Element Types in Screen Widgets
- Chapter 4: Form Widgets
- Android基础 【Chapter-3】Android widgets(Android控件)
- Pro Android学习笔记(一三七):Home Screen Widgets(3):配置Activity
- Home Screen Widgets(2):Widget定义
- pyGTK_读书笔记_Tutorial Chapter 4_Packing Widgets
- Introducing home screen widgets and the AppWidget framework (翻译)
- Android学习笔记:Home Screen Widgets(1):关于Widget
- Android学习笔记:Home Screen Widgets(2):关于Widget
- 读书笔记[Android Beginning 2] chapter 5 Employing Basic Widgets
- Chapter 5. Label and Entry Widgets 标签和输入部件
- widgets
- widgets
- Pro Android学习笔记(一三五):Home Screen Widgets(1):关于Widget
- Pro Android学习笔记(一三六):Home Screen Widgets(2):Widget定义
- Pro Android学习笔记(一三八):Home Screen Widgets(4):App Widget Provider
- ofbiz总结——Screen Widgets定义中常用的一些标签
- 使用application统计在线用户数
- FORM TEXT_ITEM内容左右靠齐
- 6_4三角形类
- StringCchPrintf
- iOS开发之工具篇-20个可以帮你简化移动app开发流程的工具
- Chapter 3: Screen Widgets
- ASP留言板代码
- Ubuntu下手动安装eclipse,不是用apt-get。
- SHELL下date命令的用法
- [交互式SVG组件]Multi-line text box
- #pragma section
- Jenkins的配置
- 成功创业者必须具备的9个特质[转载]
- 【绝密】2013高考语文复习规划