首页 > 其他 > 详细

OFBiz学习日记(一)

时间:2014-03-08 20:55:30      阅读:534      评论:0      收藏:0      [点我收藏+]

经过初步的学习,大概了解了的OFBiz框架的结构。下面做个“Hello World”的demo:

一、开发环境和版本

      1.jdk1.7

      2.eclipse-jee-kepler-SR2-win32

      3.ofbiz-release13.07

二、导入项目

      将ofbiz-release13.07 import到eclipse中

三、配置到本地

  1.cmd 到ofbiz安装目录     

      2.ant clean

      3.ant build

      4.ant load-demo

      5.java -jar ofbiz.jar

四、Hello World

  1.在hot-deploy目录下新建practice目录,这里practice为组件名

    2.practice目录下新建webappwidget目录、ofbiz-component.xml文件  

  3.ofbiz-component.xml文件代码如下: 

    <?xml version="1.0" encoding="UTF-8"?>

 

    <ofbiz-component name="practice" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
    <resource-loader name="main" type="component"/>
      <webapp name="practice"
      server="default-server"
      location="webapp/practice"
      title="Practice"
      base-permission="OFBTOOLS"
      mount-point="/practice"/>
    </ofbiz-component>

  4.webapp下新建practice目录,这里practice为应用名,practice下新建WEB-INF目录

    5.WEB-INF下新建web.xmlcontroller.xml文件

    6.web.xml文件代码如下:

   <?xml version="1.0" encoding="UTF-8"?>
   <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">

 

  <web-app>
    <display-name>Open For Business - Practice Component</display-name>
    <description>Practice Component of the Open For Business Project</description>

 

    <context-param>
      <param-name>webSiteId</param-name>
      <param-value>practiceSite</param-value>
      <description>A unique ID used to look up the WebSite entity</description>
    </context-param>
    <context-param>
      <param-name>localDispatcherName</param-name>
      <param-value>practice</param-value>
      <description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description>
    </context-param>
    <context-param>
      <param-name>entityDelegatorName</param-name>
      <param-value>default</param-value>
      <description>The Name of the Entity Delegator to use,defined in entityengine.xml</description>
    </context-param>
    <context-param>
      <param-name>mainDecoratorLocation</param-name>
      <param-value>component://practice/widget/CommonScreens.xml</param-value>
      <description>The location of the main-decorator screen to use for this webapp; referred to as a context variable in screen def XML files.         </description>
    </context-param>
    以下还有部分代码(从filter开始)可在任意其他web.xml文件中复制

  7.widget目录下新建CommonScreens.xml 文件,代码如下:

 

    <?xml version="1.0" encoding="UTF-8"?>

 

    <screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
      <screen name="hello">
      <section>
        <widgets>
          <label>Hello World</label>
        </widgets>
      </section>
    </screen>
   </screens>

  8.返回WEB-INF目录下修改controller.xml文件,代码如下:

    <?xml version="1.0" encoding="UTF-8"?>

    <site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd">
    <include location="component://common/webcommon/WEB-INF/common-controller.xml"/>
    <request-map uri="main">
      <security https="false" auth="false"/>
      <response name="success" type="view" value="main"></response>
    </request-map>
   <view-map name="main" type="screen"
      page="component://practice/widget/CommonScreens.xml#hello"></view-map>
  </site-conf>

  9.整个helloWorld应用已经搭建好,hot-deploy同级目录下的tools目录下点击startofbiz.bat启动我们的ofbiz 

  10.9. 打开浏览器输入 http://localhost:8080/practice/control/main

OFBiz学习日记(一),布布扣,bubuko.com

OFBiz学习日记(一)

原文:http://www.cnblogs.com/zhoumc/p/3587538.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!