1.เริ่มจากสร้างเข้าไปในไฟล์ controller.xml ดังภาพ
2.สร้าง request-map และ view map ในไฟล์ controller.xml ดังนี้
<request-map uri="mainmenu><security https="true" auth="true"/><response name="success" type="view" value="mainmenu"/></request-map> <view-map name="mainmenu" type="screen" page="component://ที่อยู่ไฟล์ screen.xml #mainmenu"/>3.จากนั้น controller จะเรียกใช้ screen ซึ่งภายใน screenก็จะเรียกใช้ form ที่เราสร้างเอาไว้อีกที
<screen name="mainmenu">
<section>
<actions>
<set field="headerItem" value="mainmenu"/><!-- this highlights the selected menu-item with name "main" -->
</actions>
<widgets>
<decorator-screen name="AppStudentCommonDecorator" location="${parameters.mainDecoratorLocation}">
<decorator-section name="body">
<container id="page">
<label>สร้างประวัติใหม่</label>
<include-form location="component://ที่อยู่ไฟล์Forms.xml" name="CreateStudent" />
</container>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
โดยเราจะเรียกใช้ form ไว้ในภายใต้ <decorator-screen name="AppStudentCommonDecorator" location="${parameters.mainDecoratorLocation}">คือใช้ แทมเพลทของ ofbiz เลยเพื่อที่จะสามารถสร้าง Menu Widget ใน Ofbiz ได้4.จากนั้นเราจะมาสร้างเมนู ในไฟล์ AppStudentMenus.xml หรือ Menus.xml น่ันเอง ซึ่งชื่อไฟล์จะเปลี่ยนไปตามcomponent ของคุณ
<menu name="MainAppBar" title="ระเบียนประวัติ" extends="CommonAppBarMenu" extends-resource="component://common/widget/CommonMenus.xml">
<menu-item name="mainmenu" title="สร้างประวัติใหม่"><link target="mainmenu"/></menu-item>
</menu>เพียงเท่านี้ เราก็จะสามารถสร้าง Menu Widget ใน decorator-screen ของ Ofbiz ได้แล้วคะ



0 ความคิดเห็น:
แสดงความคิดเห็น