`

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​)​,...

    实现31条mips指令的流水线cpu代码

    ​3​实​现​3​1​条​M​I​P​S​指​令​流​水​线​C​P​U​代​码​采​用​V​e​r​i​l​o​g​H​D​L​语​言​编​写​,​包​括​U​C​F​文​件​,​如​有​问​题​请​发​正​确​代​码​到...

    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

    HTTP Status Code 常见的状态码汇总

    智物通讯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​论​坛​演​示

    C++-ISO (2020).pdf

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

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

    1.掌握PPP 的基本配置步骤和方法。 2.掌握PAP、CHAP 的基本配置步骤和方法。 3.掌握对PAP、CHAP进行诊断的基本方法 1.配置路由器之间的PPP 连接。 2.配置、验证PAP过程。 3.配置、验证CHAP过程。

    7z1900_c_C语言压缩_7z7c_7z1900是什么_7z1900_7Zip_

    支持7zip压缩解压缩功能,c语言源码。

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

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

    IBMStorwizeV5000存储方案建议书(可编辑).doc

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

    filehost_z_e_n_o_n_622_S1B0_hmicrack_key_crack_Zennon_

    Crack HMI Zennon 622

    ZNE-100t.rar_ZNE_ZNE-100TL_串口 以太网_串口转以太网

    ZNE-100T增强型嵌入式以太网转串口模块,LPC213XDEMO板源码

    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读写...

    Z_N_PID_matlab_matlabpid_fuzzypid_PID控制_Z-NPID_

    用于pid控制的Z-N整定的matlab程序,调整阈值可得到精确解,适合初学者学习理解。

Global site tag (gtag.js) - Google Analytics