OFBiz's MVC framework __ Frame

Source: Internet
Author: User

OFBiz is a very powerful enterprise architecture, which only describes its MVC aspects, from the perspective of MVC, OFBiz is using the service to worker model, the famous Struts 1 is the same architecture. The goal of the Service to worker model is to maintain the separation between Action,view and controller.

Controller

Controlservlet is front Controller, receives all requests, is the request the entrance, carries on some preparation processing, gives the RequestHandler to handle the actual request work, the view layer processing is handing over to the Viewhandler to handle, Viewhandler has many implementation classes, can also be customized, can integrate a lot of page layer display technology, such as JSP and freemarker, processing process as shown in the following figure:

The decoupling of MVC is implemented through the Controller.xml configuration file, as follows: < request-map  URI = "Login" >
          < security  HTTPS = "false"  auth = "false"/>
          < event  type = "java"  path = "Com.xxx.ldap.LdapLoginWorker"  invoke = ' Login '/>
         < response  name = ' success '  type = ' View " value =" main "/>
         < response  name =" Error "  type = "View"  value = "Login"/>
</request-map >

< view-map  name = "Main"   Type = "screen"  page = "Component://xxx/widget/customerscreens.xml#main"/>

< view-map  name = " Login " type =" screen " page =" Component://xxx/widget/commonscreens.xml#login "/>

Request-map's response element has an attribute name, which can theoretically be arbitrarily selected, but OFBiz has built-in success and error values, similar to Struts 2. Property type If the view representation gets a page, the value of the value for the name attribute in View-map. The reason is not to write directly on the page, but to increase the view-map, one is to understand the coupling, the second is for different view, you can set different types and other attributes. The type attribute is critical, and it is this property that helps ofbiz integrate different display layer technologies. Common-controller defines a different type and its corresponding Viewhandler: <!--view Handlers-->
< handler name = "Screen" type = "view" class = "Org.ofbiz.widget.screen.ScreenWidgetViewHandler"/>
< handler name = "Screenfop" type = "view" class = "Org.ofbiz.widget.screen.ScreenFopViewHandler"/>
< handler name = "Screenxml" type = "view" class = "Org.ofbiz.widget.screen.ScreenXmlViewHandler"/>
< handler name = "Screentext" type = "view" class = "Org.ofbiz.widget.screen.ScreenTextViewHandler"/>
< handler name = "JSP" type = "view" class = "Org.ofbiz.webapp.view.JspViewHandler"/>
< handler name = "FTL" type = "view" class = "Org.ofbiz.webapp.ftl.FreeMarkerViewHandler"/>
< handler name = "http" type = "view" class = "Org.ofbiz.webapp.view.HttpViewHandler"/>

The name here corresponds to the type in the view map. Decoupling of the class is not front controller but RequestHandler, request proxy class, here is responsible for reading Controller.xml file in the corresponding relationship, according to front sent over the request, Select the appropriate business action for the Business update, and select the appropriate view to resolve and show. In service to worker mode, the role of the RequestHandler class is dispatcher.


View
OFBiz support many types of page display technology, Jsp/freemarker/velocity/pdf/widget and so on. The most common ofbiz are widgets and Freemarker. Widgets are ofbiz their own unique page technology, the advantage is that you can not write any HTML and CSS code can be a unified complete page, the display of business data can also be easily obtained. The disadvantage is: Unlike Freemarker is a pure page technology, from the request and session to get the business data, and then directly show its processing. Widget technology mixes business data acquisition and business data presentation, and background developers and page designers can't work together, and even only background designers can develop ofbiz applications. OFBiz design their own page technology, and ofbiz implementation of ERP/CRM complex business system is not open. ERP/CRM Business system is complex and changeable, with many modules. What kind of framework can meet such a system: first, adapt to business changes, the second is suitable for rapid development, the third page style can be consistent. OFBiz is such a framework, entity add to reduce a field, in the ofbiz only need to make changes in the Entitymodel, in the input page, display page, modify the page do not have to do any changes can see changes, And the business logic module does not have to modify the field can be changed to maintain, very easy. OFBiz suitable for rapid development, familiar with the development of the OFBiz personnel, the development of a customer module, the user to add deletions and complex inquiries, one hours enough, fast enough. With no direct manipulation of HTML and CSS code, the various modules developed using OFBiz are the same, which many designers expect. In return, it is a technical analysis of view design. In front of that, by implementing the Viewhandler interface, OFBiz integrates different page technologies for selection. The related class diagram is as follows:

View Handler:



Viewhandler is responsible for selecting the corresponding renderer, the preparation of the page display, for simple page technology such as Jsp,jspviewhandler direct processing, no longer entrusted to other renderer to deal with. In subclasses of Abstractviewhandler, the handler containing the screen word is usually relatively complex, as shown in the following handler in the previous figure, typically Screenwidgetviewhandler.

View Renderer:



Renderer is responsible for the specific display work.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.