Develop > Presentation layer > WebSphere Commerce integration with WebSphere Portal > Customize WebSphere Commerce Portal integration > Use the provided WebSphere Commerce MVCPortlet class (MVC style)


WebSphere Commerce MVCPortlet framework

The MVCPortlet framework uses the JSP model 2 architecture to interact with WebSphere Commerce. A Model-View-Controller (MVC) design pattern is used in this architecture to separate presentation from content data. The Model represents the business or database code, the View represents the rendered content on a page, and the Controller determines how a request should be processed by the Model and which View to be used for display.

The goal of this MVCPortlet is to efficiently separate the model, that is the application logic that interacts with a database, from the view, that is the HTML pages presented to the client, and the controller, that is the instance that passes information between view and model. The framework provides the controller class, known as MVCPortlet, and facilitates the writing of JSP file templates for the view. A central portlet-config.xml configuration file is used to bind together model, view and controller.

MVCPortlet is a controller that uses a MVC style portlet-config.xml configuration file to invoke appropriate client libraries provided by WebSphere Commerce. This MVCPortlet invokes the client libraries using an action class called MVCPortletActionHandler. This action class retrieves the parameters from the PortletRequest and the PortletSession and converts these into the values required by the Client Library. Portlet action request is the typical programming pattern for update operations used in this MVCPortlet framework. An event handler class called MVCPortletRenderHandler is used for determining which JSP file template to be used for rendering, based on the render defined in the portlet-config.xml configuration file.

To retrieve additional business data for rendering, the getData tag of the JSTL tag library is provided to issue read operations, that is Get service calls, against the WebSphere Commerce service modules. The result set is a list of data objects that can be used directly on the JSP file. In the MVCPortlet framework programming model, it is not recommended to perform update operations in the render phase.

The MVCPortlet framework is very similar to Struts, with the ability to make service calls to the WebSphere Commerce service modules. A portlet action request is represented as action, similar to the Actions term used in Struts, while a portlet render request is represented as render, which is equivalent to the ActionForwardstring in Struts. The purpose of render is for informing the controller which output page to be used for rendering. For passing information between the model and view, the MVCPortlet framework uses DataObject, or service data object (SDO). JSP file developers who are familiar with JavaBeans can also interpret SDO to be conceptually equivalent and can be used directly on a JSP file.

The following diagram depicts the interactions between the key components of WebSphere Commerce MVCPortlet. A brief description of the key components follows the diagram.


MVCPortlet class

MVCPortlet is a generic implementation of the MVC pattern that allows WebSphere Portal administrators to set up one or more portlets, each with its own configuration, to call various WebSphere Commerce services.


Configuration registry

The portlet configuration registry is a cached version of configurations related to all portlet operations, such as portlet actions and portlet renders. These static configurations are defined in XML files packaged as part of the WebSphere Commerce MVCPortlet application.


Event handlers

The MVCPortlet framework is designed in a flexible way so that each portlet request can be handled differently using an event handler. It is possible to define a corresponding event handler in the portlet MVC configuration file for each action event and render event. Although the MVC configuration allows you to define any customized event handler, the use of two generic event handlers is recommended:

This programming pattern greatly reduces code redundancy and maintains consistent behaviors across all WebSphere Commerce portlet events.


Portlet JSP files

The portlet JSP file is a view template for displaying business data and getting inputs from the WebSphere Portal user. Special UI tags, such as portlet tags and getData tags, are used on these pages to avoid inline JSP Java coding. Portlet tags are provided by WebSphere Portal to access information specific to the WebSphere Portal environment, whereas WebSphere Commerce getData tags are used for retrieving populated service data objects from WebSphere Commerce services.


Client libraries

A Client Library is a WebSphere Commerce component service interface for client-side service invocation. Client libraries should not be aware of any artifacts specific to WebSphere Portal, such as portlet session and credential service vault. Business objects, such as BusinessContextType and AuthenticationCallbackHandler, are passed to the interface upon each service invocation, so that it can hand over specific information to the service binding layer.


getData tag expression builders

A getData tag is provided as part of the WebSphere Commerce UI runtime. It retrieves populated service data objects from WebSphere Commerce services. See GetData tag configuration for more information.


MVCPortlet interaction flow

The following interaction diagram illustrates the high-level interaction of the MVCPortlet and the backend component services from the WebSphere Commerce server:


+

Search Tips   |   Advanced Search