首页 > 代码库 > OFBiz进阶之HelloWorld(三)使用 Form Widget

OFBiz进阶之HelloWorld(三)使用 Form Widget

1. Now add one more menu item to by name "PersonForm" to your PracticeMenus.xml file.

<menu-item name="PersonForm" title="PersonForm"><link target="PersonForm" /></menu-item>

 

2. Create one file in widget by name PracticeForms.xml and create a list form for showing the records from person entity.

    (Take reference from ExampleScreens.xml and ExampleForms.xml files).

<?xml version="1.0" encoding="UTF-8"?><forms xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"         xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-form.xsd">    <form name="ListPersons" type="list" list-name="persons" list-entry-name="person"  default-map-name="person" paginate-target="personForm">        <!-- Important: Here service definition for updatePracticePerson has been used for automatically rendering the form fields, which you can use after completing CRUD operations from Part-3 -->         <!-- auto-fields-service service-name="updatePracticePerson" default-field-type="display" map-name="person"/-->          <!-- The above method can be used in case a service specific form is being rendered, otherwise form-fields can be explicitly mentioned as given below:-->         <field name="firstName"><display/></field>         <field name="middleName" ><display/> </field>         <field name="lastName" ><display/> </field>    </form></forms>

 

3. Create new screen by name personForm and include this list form in it.

<screen name="PersonForm">        <section>            <actions>                <set field="headerItem" value="personForm"/>                <set field="titleProperty" value="PageTitlePracticePersonForm"/>                <entity-condition entity-name="Person" list="persons"/>            </actions>            <widgets>                <decorator-screen name="CommonPracticeDecorator" location="${parameters.mainDecoratorLocation}">                    <decorator-section name="body">                        <label text="Person List" style="h2"/>                        <include-form name="ListPersons" location="component://practice/widget/PracticeForms.xml"></include-form>                    </decorator-section>                </decorator-screen>                   </widgets>        </section></screen>

4. Do the needful for showing this screen in controller.xml.

Now run the application again and observe the difference.
Till Now you have worked on controller requests mappings, Screen widget, form widget, Decorator, Menus, groovy, ftl.

OFBiz进阶之HelloWorld(三)使用 Form Widget