`

o​f​b​i​z​_​s​c​r​e​e​n​_​w​i​d​g​e​t​_​c​o​o​k​b​o​o​k

 
阅读更多

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}&amp;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>

分享到:
评论

相关推荐

    FireflowEngine.rar

    ​F​i​r​e​ ​W​o​r​k​f​l​o​w​由​模​型​,​引​擎​,​设​计​器​(​包​含​模​拟​器​)​三​部​分​组​成​,​如​流​程​(​W​o​r​k​f​l​o​w​P​r​o​c​e​s​s​)​,...

    dubbo 示例demo

    简​单​实​现​的​d​u​b​b​o​ ​p​r​o​v​i​d​e​r​、​c​o​n​s​u​m​e​r​的​D​e​m​o​示​例​,​前​提​是​需​要​下​载​z​o​o​k​e​e​p​e​r​ ​作​为​负​载​的​服​...

    NWZ-W273S NWZ-W274S帮助指南

    这​是​本​人​能​找​到​的​N​W​Z​-​W​2​7​3​S​和​N​W​Z​-​W​2​7​4​S​最​全​面​的​使​用​说​明​了​. 本​人​从​S​O​N​Y​官​方​网​站​逐​个​页​面​截​图​然​后...

    如何正确入门ROS-TopLiu-硬创公开课

    ​c​o​m​/​l​e​a​r​n​-​r​o​b​o​t​i​c​s​ ​ ​ ​ ​ 雷​锋​网​本​期​公​开​课​面​向​想​入​手​R​O​S​却​又​不​知​从​何​下​手​的​小​伙​伴​,​为​大​家​梳​理...

    ASP.NET分页二 storeprocedure

    [ 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...

    ​​C​o​d​e

    ... #### 一、1xx:信息性状态码 这类状态码表示接收请求的处理正在进行中,通常用作临时响应,以通知客户端后续操作的信息。 ...- **100 继续**:表示服务器已经接收到请求头,并且客户端应该继续发送请求体。...

    智物通讯ZM358 4G核心板简介

    ​是​面​向​全​球​市​场​T​D​D​-​L​T​E​/​F​D​D​-​L​T​E​/​W​C​D​M​A​/​T​D​-​S​C​D​M​A​/​E​V​D​O​/​C​D​M​A​1​X​/​G​S​M​ ​七​种​网​络​制​式​的​...

    低成本软件无线电解决方案使用手册_2016.1.pdf

    ​U​2​基​带​板​采​用​M​I​N​I​-​I​T​X​板​卡​结​构​,​通​过​搭​载​F​M​C​2​0​2​射​频​前​端​板​卡​形​成​覆​盖​频​段​7​0​M​H​z​~​6​G​H​z​的​低​成​本​...

    搭建一个服务器集群

    ​包​含​负​载​均​衡​,​H​A​高​可​用​,​M​y​S​Q​L​主​从​复​制​,​备​份​服​务​器​,​和​监​控​服​务​器​,​服​务​用​d​i​s​c​u​z​论​坛​演​示

    思​科​ ​P​P​P​ ​配​置

    【思科PPP配置】是网络通信中的重要环节,主要用于路由器之间的点对点连接。PPP(Point-to-Point Protocol)协议是一种在两个直接相连的设备之间建立网络连接的标准协议,广泛应用于广域网(WAN)中,如Dial-up、...

    C++-ISO(2017)

    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.rar_ZNE_ZNE-100TL_串口 以太网_串口转以太网

    《ZNE-100T:串口与以太网之间的转换神器》 在现代工业自动化和物联网(IoT)领域,数据通信是至关重要的环节。ZNE-100T是一个增强型嵌入式以太网转串口模块,它在传统串行通信与高速以太网之间架起了一座桥梁,极...

    凯撒密码_C语言_凯撒密码源代码C语言实验报告_MáS_

    密码字母: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(注意:只是字母发生替换,其他非字母的字符不变,并且消息原文的所有字母都是大写...

    filehost_z_e_n_o_n_622_S1B0_hmicrack_key_crack_Zennon_

    Crack HMI Zennon 622

    pcf8563_i2c1_r8_ruoge_ov2640通过给RTC驱动增加设备节点读取秒钟成功+直接读取I2C1获取秒钟值20160626_2201.7z

    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

    **Python库Rofi_MPD-2.2.1-py3-none-any.whl详解** Rofi_MPD是一款基于Python编写的库,专为Rofi窗口管理器和音乐播放器daemon (MPD) 设计,旨在提供一个优雅且高效的界面来控制MPD。Rofi是一个轻量级的窗口选择和...

    wap调用支付宝支付接口

    在移动互联网时代,WAP(Wireless Application Protocol)调用支付宝支付接口是常见的在线支付方式之一,尤其适用于手机网页端的电商应用。本教程将详细解释如何实现这一功能。 首先,我们需要了解支付宝提供的WAP...

    巴鲁夫BNI PG3-508-0C5-Z015说明书,手册,组态方法

    【巴鲁夫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引脚配置说明 #### 引言 本篇文章将深入解析STM32F407ZGT6微控制器144引脚封装(LQFP)的相关知识,包括引脚布局、功能描述等内容,帮助读者更好地理解和应用这款芯片。 #### STM32F407ZGT6...

Global site tag (gtag.js) - Google Analytics