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),...
简单实现的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...
... #### 一、1xx:信息性状态码 这类状态码表示接收请求的处理正在进行中,通常用作临时响应,以通知客户端后续操作的信息。 ...- **100 继续**:表示服务器已经接收到请求头,并且客户端应该继续发送请求体。...
是面向全球市场TDD-LTE/FDD-LTE/WCDMA/TD-SCDMA/EVDO/CDMA1X/GSM 七种网络制式的...
U2基带板采用MINI-ITX板卡结构,通过搭载FMC202射频前端板卡形成覆盖频段70MHz~6GHz的低成本...
包含负载均衡,HA高可用,MySQL主从复制,备份服务器,和监控服务器,服务用discuz论坛演示
【思科PPP配置】是网络通信中的重要环节,主要用于路由器之间的点对点连接。PPP(Point-to-Point Protocol)协议是一种在两个直接相连的设备之间建立网络连接的标准协议,广泛应用于广域网(WAN)中,如Dial-up、...
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...
《ZNE-100T:串口与以太网之间的转换神器》 在现代工业自动化和物联网(IoT)领域,数据通信是至关重要的环节。ZNE-100T是一个增强型嵌入式以太网转串口模块,它在传统串行通信与高速以太网之间架起了一座桥梁,极...
密码字母: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(注意:只是字母发生替换,其他非字母的字符不变,并且消息原文的所有字母都是大写...
Crack HMI Zennon 622
pcf8563_i2c1_r8_ruoge_ov2640通过给RTC驱动增加设备节点读取秒钟成功+直接读取I2C1获取秒钟值20160626_2201.7z http://blog.csdn.net/21cnbao/article/details/7919055 在Android源码树中添加userspace I2C读写...
**Python库Rofi_MPD-2.2.1-py3-none-any.whl详解** Rofi_MPD是一款基于Python编写的库,专为Rofi窗口管理器和音乐播放器daemon (MPD) 设计,旨在提供一个优雅且高效的界面来控制MPD。Rofi是一个轻量级的窗口选择和...
在移动互联网时代,WAP(Wireless Application Protocol)调用支付宝支付接口是常见的在线支付方式之一,尤其适用于手机网页端的电商应用。本教程将详细解释如何实现这一功能。 首先,我们需要了解支付宝提供的WAP...
【巴鲁夫BNI PG3-508-0C5-Z015说明书与配置指南】 本说明书针对巴鲁夫(Balluff)的BNI PG3-508-0C5-Z015产品,它是一款Profinet-IO-Link-Master设备。在了解和使用该产品前,务必确保阅读此配置指南,以及相关的...
(a)电源电压角频率 =_________ , 频率 f=_____ , 周期 T=_______. (b)电压有效值U=_______,电流有效值 I=________. (c)电压、电流间相位差u–i =_________. (d)该负载是______负载, |Z|=_________, =__...
### STM32F407ZGT6 144引脚配置说明 #### 引言 本篇文章将深入解析STM32F407ZGT6微控制器144引脚封装(LQFP)的相关知识,包括引脚布局、功能描述等内容,帮助读者更好地理解和应用这款芯片。 #### STM32F407ZGT6...