Access to add and change pages is restricted. See: https://cwiki.apache.org/confluence/display/OFBIZ/Wiki+access

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 4 Next »

This document explains how OFBiz handles screen estate. It will provide an overview of the OFBiz widget system. Understanding the custom widget system is a prerequisite if you want to chance the look and feel of screens in OFBiz. Not only the internal facing screens but also the eCommerce application (the Online store) uses the home-grown OFBiz widget system to render screens. As you probably don't want to run an online store with the default layout that OFBiz comes with, you will need to understand how the OFBiz widget system is designed in order to customize the look and feel of your shop.

There are a couple more scenarious where understanding the OFBiz widget system might be helpful, for example if:

  • You intend to implement a different user interface technology for OFBiz, for example JSF, maybe in combination with AJAX.
  • You want to adapt parts of the OFBiz UI for smaller screens, for example mobile phones. 

OFBiz uses a custom widget system, partially based on the FreeMarker templating engine (http://freemarker.sourceforge.net/). But when trying to understand how to customize both the look and feel as well as the content of screens in OFBiz, FreeMarker essentially comes last. You will need to get your mind around a couple more things before templating comes to play.

Overview

The 'what' and the 'how' 

There are two aspects to a screen:

  • What data does it show.
  • How does it present that data.

A screen is usually displayed as the result of a request. In a webapp this is going to be an HTTP request, for example:

http://www.yourserver.com/partymgr/control/main

Most OFBiz URLs follow that pattern. The first part after the server name selects the webapp which is supposed to process this request. In this case, the request is for the partymgr webapp. The next part, control, determines that this request should be processed by the Controller Servlet. (See the mapping in web.xml in each webapp.) The Controller Servlet uses the control.xml file in the webapp's WEB-INF folder to decide what content to serve in response to this request.

Hint: If you wanted to integrate any functionality into OFBiz which you don't want to base on the Controller Servlet, you can use any URL namespace expect control and map it to your custom servlet.


How the Controller Servlet handles a request

The Controller Servlet is configured using the control.xml file in the WEB-INF folder. That file has three kind of XML elements which are important now:

  1. handler
  2. request-map
  3. view-map

While this is the order in which they typically appear in the control.xml file, let's start with the request-map.

Element: request-map 

Attributes: uri

Children: security, event, response

The uri attribute is used to match a request-map to the actual request. Kind in mind that the webapp name and control have already been matched by the servlet container to dispatch processing here. Therefore in our example, the remainder of the URL to match here is just main.

The request map for the URI main looks like this:

The security element specifies that https is required (https="true") and that this portion of the application required proper user authentication and authorization (auth="true"). Parts of the application which do not require either one are the online store, for example.

There is no event triggered by this request, so no processing happens in this case, as we do not have an event element. In case there is no processing, an outcome of success is the default.

The outcome of any processing (which is a string) determines which response to the request is rendered and sent back. In our example, there is only one response to choose from, which is:

The type of response is a view (type="view") with name name of "main" (value="main"). Don't get confused by the view name being identical to the URI part that the request-map matched. This is just by chance in this case. The view could be named anything, as long as there will be a view-map entry with that name.

Note: A view is not the only possible response to a request. We will discuss other potential responses later in this document. Right now, we're up to understanding how an HTML screen is rendered in a webapp in response to an HTTP request.


  • No labels