ofbiz widget-form.xsd分析总结1

78 篇文章 6 订阅

1. forms标签

froms标签是form.xml文件的根节点。文件中只会存在一个。

1.1 可包含子标签

froms标签可以包含的子标签有:form 和 grid。一般我们都是用的from。下面是form.xml文件根节点定义。一般情况下不用改。

<?xml version="1.0" encoding="UTF-8"?>
<forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
        xmlns="http://ofbiz.apache.org/Widget-Form" xsi:schemaLocation="http://ofbiz.apache.org/Widget-Form http://ofbiz.apache.org/dtds/widget-form.xsd">

2. form标签

2.1 可包含子标签

form标签可以包含的子标签按顺序排序有:

actions , row-actions , alt-row-style , alt-target , auto-fields-service , 

auto-fields-entity , field , on-event-update-area , sort-order

2.2 form标签常用属性

name

name属性是必须定义的,只有定义了name,才能方便在Screens.xml页面引用表单。

type

type取值主要有三种类型:singlelistmulti

single类型:主要用于显示填报数据表单。如何添加或修改实体时使用。

<form name="AddInternalOrg" type="single" target="createInternalOrg" default-map-name="tempObj"
        header-row-style="header-row" default-table-style="basic-table">

list类型:主要用于显示列表数据。显示查询结果。

<form name="ListFindTeacher" list-name="listIt" title="" type="list" paginate-target="FindTeacher"
        odd-row-style="alternate-row" default-table-style="basic-table hover-bar">


multi类型:主要用于显示列表数据,标签可以批量操作数据。比如批量删除操作。还可以直接在表格中修改数据。

target

target属性值表示表单提交的url。类似html中form标签的action属性。

paginate-target

该属性一般在list类型表单中定义,其值为对应的查询表单name属性值。
查询表单提交后,请求参数会传入到这个表单中。请求参数map对象为requestParameters。

3. actions标签

actions标签表示动作,actions标签一般作为form标签的子标签。
actions标签可以包含的子标签有:service , call-parent-actions , entity-and , entity-condition 

4. row-actions标签

该标签一般用于list表单。查询结果为list时,对每行记录都执行row-actions标签里的动作。

例子1(applications\accounting\widget\AgreementForms.xml):

        <row-actions>
            <script location="component://accounting/webapp/accounting/WEB-INF/actions/agreement/GetPartyNameForDate.groovy"/>
        </row-actions>         
例子2(applications\accounting\widget\ap\forms\InvoiceForms.xml):

    <form name="ListReports" type="list" separate-columns="true" title="${uiLabelMap.AccountingInvoice} ${uiLabelMap.CommonList}" list-name="invoices" target=""
        odd-row-style="alternate-row" default-table-style="basic-table hover-bar" paginate-target="main">
        <row-actions>
            <service service-name="getPartyNameForDate" result-map="partyNameResultFrom">
                <field-map field-name="partyId" from-field="partyIdFrom"/>
                <field-map field-name="compareDate" from-field="invoiceDate"/>
                <field-map field-name="lastNameFirst" value="Y"/>
            </service>
            <service service-name="getPartyNameForDate" result-map="partyNameResultTo">
                <field-map field-name="partyId" from-field="partyId"/>
                <field-map field-name="compareDate" from-field="invoiceDate"/>
                <field-map field-name="lastNameFirst" value="Y"/>
            </service>
            <set field="amountToApply" value="${groovy:
                import java.text.NumberFormat;
                return(NumberFormat.getNumberInstance(context.get("locale")).format(org.apache.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceNotApplied(delegator,invoiceId)));}"/>
            <set field="total" value="${groovy:
                import java.text.NumberFormat;
                return(NumberFormat.getNumberInstance(context.get("locale")).format(org.apache.ofbiz.accounting.invoice.InvoiceWorker.getInvoiceTotal(delegator,invoiceId)));}"/>
        </row-actions>

5. alt-row-style标签

顾名思义,该标签是修改行样式,比如显示一个列表时希望凸显符合指定条件的行,则可以使用该标签实现。

例子(specialpurpose\example\widget\example\ExampleForms.xml):

        <alt-row-style use-when="'EXST_APPROVED'.equals(statusId)" style="Validate"/>
        <alt-row-style use-when="'EXST_CANCELLED'.equals(statusId)" style="Warn"/>

6. auto-fields-service标签

该标签是自动填充表单,如果定义了该标签,会自动根据服务返回结果生成对应表单。

例子1(applications\accounting\widget\AgreementForms.xml):

<auto-fields-service service-name="updateAgreementTerm"/>

例子2:

<auto-fields-service service-name="updateContentPurposeOperation" default-field-type="display"/>
例子3(applications\content\widget\website\WebSiteForms.xml):

<auto-fields-service service-name="updateWebSiteRole" map-name="webSiteRole" />

7.auto-fields-entity标签

8.field标签

8.1 可包含子标签

可包含的子标签有:
check container date-find date-time display display-entity drop-down file hidden 
hyperlink ignored image lookup include-menu include-form include-grid include-screen 
password radio range-find reset submit text textarea text-find on-field-event-update-area

8.2 常用属性

name

name属性是必须的,表是该表单控件的名字。


map-name

该属性含义:表单上下文中包含该字段数据的map名称。
例子(applications\accounting\widget\GlForms.xml):
    <form name="EditAcctgTrans" type="single" target="updateAcctgTrans" default-map-name="acctgTrans"
        header-row-style="header-row" default-table-style="basic-table">
        <auto-fields-service service-name="updateAcctgTrans"/>
        <field name="acctgTransId"><display/></field>
        <field name="organizationPartyId" map-name="parameter"><hidden/></field>

即organizationPartyId的取值不是从默认的acctgTrans对象中获取,而是从parameter对象获取,也就是parameter.organizationPartyId

entry-name

例子(applications\accounting\widget\GlForms.xml):
        <field name="glAccountId" position="2" entry-name="resetFieldValue">
            <drop-down allow-empty="true">
                <entity-options entity-name="GlAccountOrganizationAndClass" key-field-name="glAccountId" description="${accountCode} - ${accountName} [${glAccountId}]">
                    <entity-constraint name="organizationPartyId" operator="equals" env-name="parameters.organizationPartyId"/>
                    <entity-order-by field-name="accountCode"/>
                </entity-options>
            </drop-down>
        </field>

entry-name默认值是name;用于指定映射中包含要填充的值的项的名称。

tooltip

该属性是控件后面显示提示信息。
例子:
<field use-when="teacher!=null" name="tchId" title="${uiLabelMap.BookingTeacherTchId}" tooltip="${uiLabelMap.BookingNotModification}." ><display/></field>
提示用户该字段不能编辑修改。如下图中t003后面显示 “不能修改”.

required-field

该属性的值默认为false,设置为true,则表示该字段不能为空,对应的控件后面会显示*号,如上图“张三”后面的*号。

use-when

表示当条件满足是才会创建该field,不满足则忽略。实际运用如权限控制列表中操作列,只有有权限才显示操作按钮。
例子:可以参考tooltip属性中的例子。

title

该属性对应表单中左侧的lable文本。如何tooltip属性中的图片左侧的“教师标识id”,“姓名”等都是title属性定义的。


9.on-event-update-area

当对应表单事件发生时,指定局域会自动刷新。

9.1可包含的子标签

按顺序包含三个子标签(可以没有,但是顺序不反了。):
auto-parameters-service auto-parameters-entity parameter

9.2包含的属性

event-type:必须,枚举类型,取值有:paginate sort-column submit, 分别表示分页,排序,提交事件。
area-id:必须,字符串,该值一般是容器的id,如<container>或者<div>标签的id属性。表示该区域要局部刷新。
area-target:必须,字符串,局部刷新的请求url。类似ajax的url参数。

10.sort-order

这个不常用。














  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值