THE SCREEN-WIDGET COOKBOOK
==========================
This document is a series of HOWTOs on using the OFBIZ screen-widget to create screens.
* How to check for a permission FOO_ACTION and render a widget if it passes or a failure widget if it fails
<decorator-section name="foo">
<section>
<condition><if-has-permission permission="FOO" action="_ACTION"/></condition>
<widgets><!-- condition success widgets go here --></widgets>
<fail-widgets>
<!-- condition failure widgets go here -->
<label style="head3">${uiLabelMap.FooActionPermissionError}</label>
</fail-widgets>
</section>
</decorator-section>
* How to test a value in the context to see if widgets should render or not
<section>
<condition><if-compare field-name="objectInContext" operator="equals" value="true" type="Boolean"/></condition>
<widgets> These will render if condition passes </widgets>
<fail-widgets> Otherwise, these widgets will render </fail-widgets>
</section>
- You can place the <section> block anywhere underneath a <widgets> or <fail-widgets> to acheive nested conditions:
<widgets> ....
<section>
<condition>...</condition>
<widgets> ...
<section>
<condition>....</condition>
<widgets/>
</section>
</widgets>
<fail-widgets><section>...</section></fail-widgets>
</section>
</widgets>
- You can group conditions by wrapping them with <and>, <or>, <xor> and inverse the sense with <not>:
<condition><not><and><if-compare one/><if-compare two/></and></not></condition>
- There is a <if-empty field="fieldName"> condition for testing if a value is null or not-defined
* Note on using uiLabelMap within screens
Usually the "main-decorator" would define the uiLabelMap, but these cannot be accessed from higher level screens due to the way
<actions> are executed. Avoid using uiLabelMaps within the screens except in the <widgets> section. Instead, define the name of
the map to be called, such as "CommonLogin" in a parameter and then call this uiLabelMap from within the template file. For example,
<actions>
<set field="someField" value="CommonLogin"/> <!-- then use in the templates with ${uiLabelMap.get(someField)} -->
<set field="anotherField" from-field="uiLabelMap.CommonLogin"/> <!-- This won't work! uiLabelMap is not defined yet -->
</actions>
<widgets>
<label style="head3">${uiLabelMap.CommonLogin}</label> <!-- this is the only exception: you can use the context variables inside <widgets> -->
</widgets>
This especially applies to page titles you might want to set for specific screens. That's why you see screen sections define a pageTitleLabel="CommonLogin"
rather than reference uiLabelMap directly.
* How to set data in the <actions> tag for later use
* How to get a single enity in the <actions> section and store in a value
<set field="entityPrimaryKeyId" from-field="parameters.entityPrimaryKeyId"/>
<entity-one entity-name="EntityName" value-name="entityValue"/>
* How to create a two column screen. This comes from a real main-decorator
<!-- This is a box around the main content of the application under the section tabbar -->
<container style="centerarea">
<!-- subheader includes a place to put the title and login/logout buttons -->
<platform-specific><html><html-template location="component://crmsfa/webapp/crmsfa/includes/subheader.ftl"/></html></platform-specific>
<!-- a div of class "contentarea" -->
<container style="contentarea">
<!-- a div of id "column-container" -->
<container id="column-container">
TODO: insert code to show explicit columns
<!-- will render shortcuts only if shortcutsScreenName value not empty -->
<include-screen name="${shortcutsScreenName}"/>
<!-- The main column where most of the content goes. -->
<container>
<!-- Draw any messages, such as errors. TODO: use our own prettier version -->
<platform-specific><html><html-template location="component://common/webcommon/includes/messages.ftl"/></html></platform-specific>
<!-- Finally, include the section screen -->
<decorator-section-include name="section-decorator"/>
</container>
</container>
</container>
</container>
* How to accept a partyId parameter from a link and also have a partyId input parameter in a form without conflict
If you wish to have a form that accepts a partyId but also fills it in from a URL parameter, you may run into an error where the partyId was read as an
array with two values. This is because the screen widget isn't very smart about handling request parameters + forms. It will combine the URL parameter partyId
and the form parameter partyId into an array keyed to parameters.get("partyId"). order to get around this, do the following at the top of your beanshell
script before the form is rendered.
partyId = request.getParameter("partyId"); // check actual URL parameters first
if (partyId == null) parameters.get("partyId"); // if none, it's safe that this is a form parameter and not an array
* Setting properties file values
You can set values from .properties files for use in the screens by doing this:
<property-field field="defaultCurrencyUomId" resource="general" property="currency.uom.id.default" default="USD"/>
where resource denotes which properties file (in this case, "general.properties") and the property is the property to use.
Note that this does not have a global="true" attribute, so it can only be set for the screen that is using it, not globally
in a decorator.
* Paginating your forms
You need to set the VIEW_INDEX and VIEW_SIZE in your form-widget so that your forms will paginate properly. They can be set in the
<actions> section of your screen like this:
<set field="viewIndex" from-field="parameters.VIEW_INDEX" type="Integer" default-value="0"/>
<set field="viewSize" from-field="parameters.VIEW_SIZE" type="Integer" default-value="20"/>
In opentaps 0.9 and earlier versions, make sure you set those default-values. Otherwise, your first page might be a negative value,
or your screen might show 100 records at a time.
If you are using an older version of ofbiz and need to pass additional
parameters with the Next and Previous links, put a parameter "queryString"
in the <actions> section as follows,
<set field="queryString" value="partyId=${parameters.partyID}&orderId=${parameters.orderId}"/>
* Order of Execution of <actions>
TODO: describe the problem with the order of execution of <actions>, the
need to set some global variables, and how to work around it. For instance,
we can't do this,
<actions>
<set field="label" value="${uiLabelMap.SomeLabel}"/>
</actions>
<widgets>
<!-- include the GlobalDecorator's main-decorator here, which
has an <actions> that sets the uiLabelMap. -->
</widgets>
That is because the first actions to be executed are the ones in the screen
that is invoked. This is an event-based parsing system and is quite logical.
* How to set a conditional header item
In the financials application, the same payment screen could belong in either the Receivables or Payables tab, so we had to set it conditionally like this:
in the editPayment.bsh, inside an if block:
parameters.put("headerItem","receivables");
in the PaymentScreens.xml AFTER the .bsh is executed:
<set field="headerItem" from-field="parameters.headerItem"/>
* How to access page attributes in screens
The screen widget sets a Map (actually a javolution FastMap) called "page" which can be used in the Freemarker and Beanshell templates to access
the parameters set in the screen. Here is an example of it from the ecommerce application:
page = [leftbarScreenName=leftbar, rightbarScreenName=rightbar, MainColumnStyle=nocolumns, titleProperty=PageTitleCategoryPage, layoutSettings=[extraHead=<link rel="stylesheet" href="/content/images/contentForum.css" type="text/css"/>]]
and here is an example of how to use it in the FTL, from header.ftl of the ecommerce application:
<#if page.title?has_content>${page.title}<#elseif page.titleProperty?has_content>${uiLabelMap.get(page.titleProperty)}</#if>
相关推荐
Fire Workflow由模型,引擎,设计器(包含模拟器)三部分组成,如流程(WorkflowProcess),...
3实现31条MIPS指令流水线CPU代码采用VerilogHDL语言编写,包括UCF文件,如有问题请发正确代码到...
简单实现的dubbo provider、consumer的Demo示例,前提是需要下载zookeeper 作为负载的服...
这是本人能找到的NWZ-W273S和NWZ-W274S最全面的使用说明了. 本人从SONY官方网站逐个页面截图然后...
com/learn-robotics 雷锋网本期公开课面向想入手ROS却又不知从何下手的小伙伴,为大家梳理...
[ P a g i n g _ R o w C o u n t ] ' ) a n d O B J E C T P R O P E R T Y ( i d , N ' I s P r o c e d u r e ' ) = 1 ) d r o p p r o c e d u r e [ d b o ] . [ P a g i n g _ R o w C o u n t ] G O...
HTTP Status Code 常见的状态码汇总
是面向全球市场TDD-LTE/FDD-LTE/WCDMA/TD-SCDMA/EVDO/CDMA1X/GSM 七种网络制式的...
U2基带板采用MINI-ITX板卡结构,通过搭载FMC202射频前端板卡形成覆盖频段70MHz~6GHz的低成本...
包含负载均衡,HA高可用,MySQL主从复制,备份服务器,和监控服务器,服务用discuz论坛演示
C++2020标准,I S O ( t h e I n t e r n a t i o n a l O r g a n i z a t i o n fo r S t a n d a r d i z a t i o n ) i s a w o r l d w i d e fe d e r a t i o n o f n a t i o n a l s t a n d a r d s b o d...
1.掌握PPP 的基本配置步骤和方法。 2.掌握PAP、CHAP 的基本配置步骤和方法。 3.掌握对PAP、CHAP进行诊断的基本方法 1.配置路由器之间的PPP 连接。 2.配置、验证PAP过程。 3.配置、验证CHAP过程。
支持7zip压缩解压缩功能,c语言源码。
C++2017标准,I S O ( t h e I n t e r n a t i o n a l O r g a n i z a t i o n fo r S t a n d a r d i z a t i o n ) i s a w o r l d w i d e fe d e r a t i o n o f n a t i o n a l s t a n d a r d s b o d...
密码字母:A B C D E F G H I J K L M N O P Q R S T U V W X Y Z原文字母:V W X Y Z A B C D E F G H I J K L M N O P Q R S T U(注意:只是字母发生替换,其他非字母的字符不变,并且消息原文的所有字母都是大写...
I B M S t o r w i z e V 5 0 0 0存 储 解 决 方 案 建 议 书I B M C o r p o r a t i o n 2 0 1 2A l l R i g h t s R e s e r v e dI B M i s a r e g i s t e r e d t r a d e m a r k o f I n t e r n a t i o n...
Crack HMI Zennon 622
ZNE-100T增强型嵌入式以太网转串口模块,LPC213XDEMO板源码
pcf8563_i2c1_r8_ruoge_ov2640通过给RTC驱动增加设备节点读取秒钟成功+直接读取I2C1获取秒钟值20160626_2201.7z http://blog.csdn.net/21cnbao/article/details/7919055 在Android源码树中添加userspace I2C读写...
用于pid控制的Z-N整定的matlab程序,调整阈值可得到精确解,适合初学者学习理解。