OFBIZ.12.4的一个简单例子
最近在研究OFBIZ,在12.4的版本下写一个最简单的例子。
1. 首先在hot-deploy下面建各种文件以及文件夹,结构如图所示
2.ofbiz-component.xml文件如下
<?xml version="1.0" encoding="UTF-8"?><ofbiz-component name="simple" 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="simple" title="Simple" server="default-server" base-permission="OFBTOOLS" location="webapp/simple" mount-point="/simple" app-bar-display="false"/> </ofbiz-component>
<?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="main"> <section> <widgets> <label text="This is first simple"/> </widgets> </section> </screen></screens>
<%response.sendRedirect("control/main");%>
<?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>simple</display-name> <description>The First Hello World Application</description> <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>localDispatcherName</param-name> <param-value>simple</param-value> <description>A unique name used to identify/recognize the local dispatcher for the Service Engine</description> </context-param> <context-param> <param-name>mainDecoratorLocation</param-name> <param-value>component://simple/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> <filter-name>ContextFilter</filter-name> <display-name>ContextFilter</display-name> <filter-class>org.ofbiz.webapp.control.ContextFilter</filter-class> <init-param> <param-name>disableContextSecurity</param-name> <param-value>N</param-value> </init-param> <init-param> <param-name>allowedPaths</param-name> <param-value>/control:/select:/index.html:/index.jsp:/default.html: /default.jsp:/images:/includes/maincss.css</param-value> </init-param> <init-param> <param-name>errorCode</param-name> <param-value>403</param-value> </init-param> <init-param> <param-name>redirectPath</param-name> <param-value>/control/main</param-value> </init-param> </filter> <filter-mapping> <filter-name>ContextFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <listener><listener-class> org.ofbiz.webapp.control.ControlEventListener</listener-class></listener> <listener><listener-class> org.ofbiz.webapp.control.LoginEventListener</listener-class></listener> <!-- NOTE: not all app servers support mounting implementations of the HttpSessionActivationListener interface --> <!-- <listener><listener-class> org.ofbiz.webapp.control.ControlActivationEventListener</listener-class></listener> --> <servlet> <servlet-name>ControlServlet</servlet-name> <display-name>ControlServlet</display-name> <description>Main Control Servlet</description> <servlet-class>org.ofbiz.webapp.control.ControlServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>ControlServlet</servlet-name> <url-pattern>/control/*</url-pattern> </servlet-mapping> <session-config> <session-timeout>60</session-timeout> <!-- in minutes --> </session-config> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
<?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"/> <description>Practice Component Site Configuration File</description> <owner>Copyright 2001-2009 The Apache Software Foundation</owner> <handler name="screen" type="view" auth="false"/> <response name="success" type="view" value="main"/> </request-map> <!-- end of request mappings --> <!-- View Mappings --> <view-map name="main" type="screen" page="component://simple/widget/SimpleScreens.xml#main"/> <!-- change the path to the following if the above doesn't work for you --> <!-- <view-map name="main" type="screen" page="component://practice/webapp/practice/widget/PracticeScreens.xml#main"/> --> <!-- end of view mappings --></site-conf>