OFBIZ.12.4的一个简单例子

  最近在研究OFBIZ,在12.4的版本下写一个最简单的例子。


   1. 首先在hot-deploy下面建各种文件以及文件夹,结构如图所示



   2.ofbiz-component.xml文件如下
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <ofbiz-component name="simple" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/ofbiz-component.xsd">
  4. <resource-loader name="main" type="component"/>
  5. <webapp name="simple"
  6. title="Simple"
  7. server="default-server"
  8. base-permission="OFBTOOLS"
  9. location="webapp/simple"
  10. mount-point="/simple"
  11. app-bar-display="false"/>
  12. </ofbiz-component>
复制代码


  3.SimpleScreens.xml文件如下
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <screens xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/widget-screen.xsd">
  4. <screen name="main">
  5. <section>
  6. <widgets>
  7. <label text="This is first simple"/>
  8. </widgets>
  9. </section>
  10. </screen>
  11. </screens>
复制代码


   4.index.jsp 内容如下
  1. <%response.sendRedirect("control/main");%>
复制代码

   
   5. web.xml内容如下
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" "http://java.sun.com/dtd/web-app_2_3.dtd">
  3. <web-app>
  4. <display-name>simple</display-name>
  5. <description>The First Hello World Application</description>
  6. <context-param>
  7. <param-name>entityDelegatorName</param-name>
  8. <param-value>default</param-value>
  9. <description>The Name of the Entity Delegator to use, defined in entityengine.xml</description>
  10. </context-param>
  11. <context-param>
  12. <param-name>localDispatcherName</param-name>
  13. <param-value>simple</param-value>
  14. <description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description>
  15. </context-param>
  16. <context-param>
  17. <param-name>mainDecoratorLocation</param-name>
  18. <param-value>component://simple/widget/CommonScreens.xml</param-value>
  19. <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>
  20. </context-param>
  21. <filter>
  22. <filter-name>ContextFilter</filter-name>
  23. <display-name>ContextFilter</display-name>
  24. <filter-class>org.ofbiz.webapp.control.ContextFilter</filter-class>
  25. <init-param>
  26. <param-name>disableContextSecurity</param-name>
  27. <param-value>N</param-value>
  28. </init-param>
  29. <init-param>
  30. <param-name>allowedPaths</param-name>
  31. <param-value>/control:/select:/index.html:/index.jsp:/default.html:
  32. /default.jsp:/images:/includes/maincss.css</param-value>
  33. </init-param>
  34. <init-param>
  35. <param-name>errorCode</param-name>
  36. <param-value>403</param-value>
  37. </init-param>
  38. <init-param>
  39. <param-name>redirectPath</param-name>
  40. <param-value>/control/main</param-value>
  41. </init-param>
  42. </filter>
  43. <filter-mapping>
  44. <filter-name>ContextFilter</filter-name>
  45. <url-pattern>/*</url-pattern>
  46. </filter-mapping>
  47. <listener><listener-class>
  48. org.ofbiz.webapp.control.ControlEventListener</listener-class></listener>
  49. <listener><listener-class>
  50. org.ofbiz.webapp.control.LoginEventListener</listener-class></listener>
  51. <!-- NOTE: not all app servers support mounting implementations of the HttpSessionActivationListener interface -->
  52. <!-- <listener><listener-class>
  53. org.ofbiz.webapp.control.ControlActivationEventListener</listener-class></listener> -->
  54. <servlet>
  55. <servlet-name>ControlServlet</servlet-name>
  56. <display-name>ControlServlet</display-name>
  57. <description>Main Control Servlet</description>
  58. <servlet-class>org.ofbiz.webapp.control.ControlServlet</servlet-class>
  59. <load-on-startup>1</load-on-startup>
  60. </servlet>
  61. <servlet-mapping>
  62. <servlet-name>ControlServlet</servlet-name>
  63. <url-pattern>/control/*</url-pattern>
  64. </servlet-mapping>
  65. <session-config>
  66. <session-timeout>60</session-timeout> <!-- in minutes -->
  67. </session-config>
  68. <welcome-file-list>
  69. <welcome-file>index.jsp</welcome-file>
  70. </welcome-file-list>
  71. </web-app>
复制代码


   6. controller.xml内容如下
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <site-conf xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  3. xsi:noNamespaceSchemaLocation="http://ofbiz.apache.org/dtds/site-conf.xsd">
  4. <include location="component://common/webcommon/WEB-INF/common-controller.xml"/>
  5. <description>Practice Component Site Configuration File</description>
  6. <owner>Copyright 2001-2009 The Apache Software Foundation</owner>
  7. <handler name="screen" type="view" />
  8. <!-- Request Mappings -->
  9. <request-map uri="main">
  10. <security https="false" auth="false"/>
  11. <response name="success" type="view" value="main"/>
  12. </request-map>
  13. <!-- end of request mappings -->
  14. <!-- View Mappings -->
  15. <view-map name="main" type="screen" page="component://simple/widget/SimpleScreens.xml#main"/>
  16. <!-- change the path to the following if the above doesn't work for you -->
  17. <!-- <view-map name="main" type="screen" page="component://practice/webapp/practice/widget/PracticeScreens.xml#main"/> -->
  18. <!-- end of view mappings -->
  19. </site-conf>
复制代码


   7. 运行的结果如下:


   注意几点:
   1. 在这里不要main.ftl文件, 所展示的内容就是SimpleScreens.xml里面的东西
   2. opentaps里面的东西有点老,虽然是Si写的
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值