- 浏览: 10714 次
- 性别:
文章分类
最新评论
Part 2
Doing Some Advancements To User Interface
Now it is time to create a decorator for the screens in this application. Create a file named CommonScreens.xml in the "widget" directory. This file will contain the common screens which will be used throughout the entire application. A common screen may have a header and footer included so any other screens that use it as a decorator will also have those items. For this you can take reference from the CommonScreens.xml file in the "example" component.
CommonScreens.xml file code will be:
<screen name="CommonPracticeDecorator">
<section>
<widgets>
<decorator-section-include name="body"/>
</widgets>
</section>
</screen>
Refer to the "CommonScreens.xml" file in the "Example" component to see usage of main-decorator. Two important readings at this moment are Understanding the OFBiz Widget Toolkit and "The Decorator" section in FAQ.
Add reference in web.xml to the CommonScreens.xml
<context-param>
<param-name>commonDecoratorLocation</param-name>
<param-value>component://practice/webapp/practice/widget/CommonScreens.xml</param-value>
<description>The location of the common-decorator screen to use for this webapp; referred to as a context variable in screen def XML files.</description>
</context-param>
Create a menu for this application. For this create a file by name PracticeMenus.xml in "widget" directory of you component. For this take a reference from ExampleMenus.xml file of "example" component.
<?xml version="1.0" encoding="UTF-8"?>
<menus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-menu.xsd">
<menu name="PracticeAppBar" title="PracticeApplication" extends="CommonAppBarMenu" extends-resource="component://common/widget/CommonMenus.xml">
<menu-item name="main" title="Main"><link target="main"/></menu-item>
</menu>
</menus>
Include this menus file in your CommonPracticeDecorator as follows:
<screen name="CommonPracticeDecorator">
<section>
<widgets>
<include-menu location="component://practice/webapp/practice/widget/PracticeMenus.xml" name="PracticeAppBar"/>
<decorator-section-include name="body"/>
</widgets>
</section>
</screen>
Create the sub-directory "actions" inside the WEB-INF directory.
In this directory we will create the scripting files. Scripting files are used to prepare data on fly. These files will be groovy files. Earlier we were using bsh(beanshell) files. This is a script which is used to fetch the data from database on the fly for the UI.
Reference : Tips & Tricks while working with Groovy & http://groovy.codehaus.org/. While working in groovy always be conscious about the imported classes and packages. Import only those which have been used in your file. For putting log messages use methods from "Debug" class just do this practice from the beginning itself. So create a file by name Person.groovy in this actions directory which will be fetching all the records from the entity "Person". At this moment this is really going to be the small code for doing this (a single line) like
context.persons = delegator.findList("Person", null, null, null, null, false);
The above statement will fetch all the records from the Person entity and will put them in context by the name persons. Now this list by the name person will be iterated in the ftl file to show the records.
At this place an important reading is available at : Which variables are available in screen context?
Now in webapp "practice" create one ftl file by name "Person.ftl" which will be used to show the data fetched by groovy file.
Reference : http://freemarker.sourceforge.net/docs/
At this moment you need only to iterate the list of persons which is there in the context. The only code that is needed to that is:
<#if persons?has_content>
<h2>Some of the people who visited our site are:</h2>
<br>
<ul>
<#list persons as person>
<li>${person.firstName?if_exists} ${person.lastName?if_exists}</li>
</#list>
</ul>
</#if>
Now create a new screen by name "person" in PracticeScreens.xml file and also create a new menu item in PracticeMenus.xml file.
PracticeScreens.xml new screen entry will be:
<screen name="person">
<section>
<actions>
<script location="component://practice/webapp/practice/WEB-INF/actions/Person.groovy"/>
</actions>
<widgets>
<decorator-screen name="CommonPracticeDecorator" location="${parameters.commonDecoratorLocation}">
<decorator-section name="body">
<platform-specific>
<html>
<html-template location="component://practice/webapp/practice/Person.ftl"/>
</html>
</platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
Now change the controller.xml file so it points to the new screen, as we did earlier.
Now again run the application and observe the results by giving http://localhost:8080/practice/control/person .
Hint
Icon
If the output screen does not contain the menu as shown below, you will most likely need to change auth="true" to auth="false" in your controller.xml for the menu to come up.
Output Screen :
Doing Some Advancements To User Interface
Now it is time to create a decorator for the screens in this application. Create a file named CommonScreens.xml in the "widget" directory. This file will contain the common screens which will be used throughout the entire application. A common screen may have a header and footer included so any other screens that use it as a decorator will also have those items. For this you can take reference from the CommonScreens.xml file in the "example" component.
CommonScreens.xml file code will be:
<screen name="CommonPracticeDecorator">
<section>
<widgets>
<decorator-section-include name="body"/>
</widgets>
</section>
</screen>
Refer to the "CommonScreens.xml" file in the "Example" component to see usage of main-decorator. Two important readings at this moment are Understanding the OFBiz Widget Toolkit and "The Decorator" section in FAQ.
Add reference in web.xml to the CommonScreens.xml
<context-param>
<param-name>commonDecoratorLocation</param-name>
<param-value>component://practice/webapp/practice/widget/CommonScreens.xml</param-value>
<description>The location of the common-decorator screen to use for this webapp; referred to as a context variable in screen def XML files.</description>
</context-param>
Create a menu for this application. For this create a file by name PracticeMenus.xml in "widget" directory of you component. For this take a reference from ExampleMenus.xml file of "example" component.
<?xml version="1.0" encoding="UTF-8"?>
<menus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-menu.xsd">
<menu name="PracticeAppBar" title="PracticeApplication" extends="CommonAppBarMenu" extends-resource="component://common/widget/CommonMenus.xml">
<menu-item name="main" title="Main"><link target="main"/></menu-item>
</menu>
</menus>
Include this menus file in your CommonPracticeDecorator as follows:
<screen name="CommonPracticeDecorator">
<section>
<widgets>
<include-menu location="component://practice/webapp/practice/widget/PracticeMenus.xml" name="PracticeAppBar"/>
<decorator-section-include name="body"/>
</widgets>
</section>
</screen>
Create the sub-directory "actions" inside the WEB-INF directory.
In this directory we will create the scripting files. Scripting files are used to prepare data on fly. These files will be groovy files. Earlier we were using bsh(beanshell) files. This is a script which is used to fetch the data from database on the fly for the UI.
Reference : Tips & Tricks while working with Groovy & http://groovy.codehaus.org/. While working in groovy always be conscious about the imported classes and packages. Import only those which have been used in your file. For putting log messages use methods from "Debug" class just do this practice from the beginning itself. So create a file by name Person.groovy in this actions directory which will be fetching all the records from the entity "Person". At this moment this is really going to be the small code for doing this (a single line) like
context.persons = delegator.findList("Person", null, null, null, null, false);
The above statement will fetch all the records from the Person entity and will put them in context by the name persons. Now this list by the name person will be iterated in the ftl file to show the records.
At this place an important reading is available at : Which variables are available in screen context?
Now in webapp "practice" create one ftl file by name "Person.ftl" which will be used to show the data fetched by groovy file.
Reference : http://freemarker.sourceforge.net/docs/
At this moment you need only to iterate the list of persons which is there in the context. The only code that is needed to that is:
<#if persons?has_content>
<h2>Some of the people who visited our site are:</h2>
<br>
<ul>
<#list persons as person>
<li>${person.firstName?if_exists} ${person.lastName?if_exists}</li>
</#list>
</ul>
</#if>
Now create a new screen by name "person" in PracticeScreens.xml file and also create a new menu item in PracticeMenus.xml file.
PracticeScreens.xml new screen entry will be:
<screen name="person">
<section>
<actions>
<script location="component://practice/webapp/practice/WEB-INF/actions/Person.groovy"/>
</actions>
<widgets>
<decorator-screen name="CommonPracticeDecorator" location="${parameters.commonDecoratorLocation}">
<decorator-section name="body">
<platform-specific>
<html>
<html-template location="component://practice/webapp/practice/Person.ftl"/>
</html>
</platform-specific>
</decorator-section>
</decorator-screen>
</widgets>
</section>
</screen>
Now change the controller.xml file so it points to the new screen, as we did earlier.
Now again run the application and observe the results by giving http://localhost:8080/practice/control/person .
Hint
Icon
If the output screen does not contain the menu as shown below, you will most likely need to change auth="true" to auth="false" in your controller.xml for the menu to come up.
Output Screen :
发表评论
-
OFBIZDEMO都如此强大
2014-07-25 13:38 371OFBIZ,DEMO都如此强大,真是一笔财富。小样,你不老实说 ... -
ofbiz入门教程(3)上心得
2014-07-24 13:30 4621、官方资料未具体写出control.xml的配置,但必须修改 ... -
ofbiz入门心得
2014-07-24 13:21 432controller.xml的作用类似struct2的stru ... -
ofbiz入门教程(2)
2014-07-24 13:15 750Part 1 Create a Component Creat ... -
ofbiz启动
2014-07-23 10:44 407Quick start Java 1.6 (minimum) ... -
ofbiz教程说明
2014-07-23 10:39 686需要中文翻译的请留言,我有时间为大家翻译 -
ofbiz入门教程(1)
2014-07-21 16:51 467ofbiz入门开发 本教程适合开发OFBIZ初学者。这将有助于 ...
相关推荐
### Ofbiz 入门教程详解 #### 一、Ofbiz 概述与环境搭建 **1. Ofbiz 简介** Ofbiz 是一个开源的企业级应用框架,它提供了全面的功能来支持电子商务业务流程,包括销售、库存管理、订单处理等。作为 Apache 软件...
### Ofbiz 入门教程详解 #### 一、Ofbiz 概述 Ofbiz(Open for Business)是一款开源的企业级商务应用系统,它利用了一系列优秀的开源项目如Tomcat、Ant、BeanShell、Jboss等,构建出了一个强大的系统平台。Ofbiz...
3. 更新 entityengine.xml 和 entitygroup.xml 文件:在 entityengine.xml 中添加对 entitymodel_study.xml 的引用,在 entitygroup.xml 中注册 StudyCustomer 实体。 4. 创建数据库表:运行Ofbiz的ant脚本或使用...
《OFBiz经典入门教程加速度编写》是一篇针对开源企业应用框架OFBiz的入门教程,旨在帮助初学者快速掌握OFBiz的基本使用和开发技巧。OFBiz(Open For Business Project)是一个全面的企业级业务应用程序框架,它由...
在本教程中,我们将深入探讨如何入门Apache Ofbiz的开发,这是一个开源的企业级应用框架,专为电子商务、供应链管理和企业资源规划等业务流程设计。Ofbiz提供了强大的组件化架构,使得开发者可以方便地构建和扩展...
【标题】"Ofbiz入门实例(jiasudu制作)"是一个针对开源企业应用系统Ofbiz的实践教程,由博主jiasudu精心制作。这个实例教程旨在帮助初学者快速理解并上手Ofbiz,从而能够构建和管理自己的企业级应用程序。 【描述】...
【OFBIZ快速入门】 OFBiz,全称Open For Business Project,是一个开源的企业级应用框架,专注于电子商务和业务流程管理。OFBiz旨在提供一个全面、可扩展且灵活的解决方案,适用于各种规模的企业。本篇文章将带你...
Apache OFBiz是一个开源...总之,OFBiz入门涉及环境配置、组件和应用的创建、实体模型定义以及CRUD操作的实现。通过这些步骤,你可以开始开发基于OFBiz的业务应用程序,利用其强大的功能和灵活性来满足企业的各种需求。
Ofbiz社区提供了大量的文档和教程,包括官方的用户指南、开发者手册以及在线论坛,这些都是学习Ofbiz的宝贵资源。同时,阅读和理解Ofbiz的源码,能够帮助你更深入地理解其工作原理。 总结来说,Ofbiz是一个功能强大...
总的来说,《Ofbiz快速开发入门详解》是一本实用的教程,适合对Java Web开发感兴趣,希望掌握企业级应用框架的开发者。通过这本书,你不仅能理解Ofbiz的基本架构,还能学会如何利用Ofbiz快速开发出满足业务需求的...
本教程旨在为初次接触OFBiz框架的开发者提供一个全面且易于理解的入门指南。OFBiz是一个开源的企业级电子商务框架,提供了完整的业务流程管理解决方案,包括订单处理、库存管理、客户服务支持等功能。通过本教程的...
NULL 博文链接:https://jiasudu.iteye.com/blog/2091874
**OFBiz开发教程** OFBiz,全称Open For Business Project,是一个开源的企业级应用套件,主要用于构建电子商务、供应链管理、客户关系管理等业务系统。本教程专为初学者设计,旨在帮助您快速掌握OFBiz的基本操作和...
**OFBIZ 10.04 组件开发入门** OFBIZ,全称为Open For Business Project,是一个基于Java的企业级应用框架,主要用于构建电子商务、供应链管理、CRM等复杂业务系统。本文档主要针对OFBIZ 10.04版本,通过讲解Region...
"OFBiz开发快速入门.pdf"很可能是详细的教程文档,它可能涵盖OFBiz的安装步骤、基本操作、API使用示例以及最佳实践。"OFBiz其它资源.txt"可能包含进一步的学习资源链接、社区论坛地址或常见问题解答。至于"hello...
OFBiz开发快速入门.rar OFBiz-技术文档.rar OFBiz API中文版.rar Apache OFBiz Cookbook Sep 2010.rar Opentaps widget使用说明.rar OFBiz.Development.2008.rar Groovy中文教程.rar freemarker中文手册.rar ...
本教程专为初学者设计,旨在解决OFBiz入门过程中的常见问题,帮助开发者快速理解并掌握OFBiz的基本操作和开发流程。 **1. 创建组件定义文件** 在OFBiz中,每个组件都是一个独立的功能模块。首先,你需要在`hot-...