SmartSync API Overview  |  Defining a SyncBo  |  Server Prerequisites for the Example

 

SmartSync Example - Inventory

This example uses inventory data to demonstrate the following features of the SmartSync API:

The MDK provides a template for this example. Click here to download template for JSP or download template for AWT.

The example needs the right Bapi wrappers to work correctly. Please refer to the document Server Prerequisites for the Example for details.


Layout

Header Panel

The tableViewDefinition bean provides to methods to set the icon on the left hand side and the text on the right hand side. The icon can be used to navigate back to the MI home page.

Center Page

The center page is divided into the following sections:

Footer Panel

The tableViewDefinition bean provides to methods to set the text on the left and right hand side of the footer panel.

Components

Java - default package

Description
ControllerServlet.java Implementation of the servlet. Handles the events and sets the bean.
Constants.java Interface defining all text strings used in PersistenceExample.java.

Java - dataAccess package

Description
SmartSyncDBAccess.java Contains all calls to the SmartSync API. Points of interest is the getSynBoInstances() method that shows the usage of the SmartSyncQueryFactory.

Java - bean package

Description
BasicDataHandler.java This class handles the data. It is directly connected to the persistence classes in the datafactory package. When the user navigates to another page the BasicDataHandler takes care to get the proper data in a vector. This data is than displayed with the JSP.
TableViewDefinition.java Implementation of the bean that is loaded by the servlet and read by the JSP. It contains the layout information and text strings for the JSP.

JSP

Description
menu.jsp Initial JSP to display the SyncBo.
query.jsp JSP to enter a filter string.
add.jsp JSP to add an entry.
savefailed.jsp JSP to display an error message, when the saving of the quantity value failed.

What does the Example

The user interface of the initial screen has a display area and three buttons:

Implemented Classes in the Servlet for the Example

We create a class ControllerServlet that extends the class AbstractMEHttpServlet and implements Constants. Constants is an interface in which we define all relevant variables for the application. All variables used in Constants are written in uppercase characters. So anytime you see an uppercase variable used in class ControllerServlet you will find the definition in interface Constants.

The class ControllerServlet extends AbstractMEHttpServlet which extends javax.servlet.http.HttpServlet itself. The application is separated into the default package (containing all classes necessary to interact with the user), the dataAccess package (containing all classes necessary to manipulate the persisted data) and bean package (which contains the bean which serves as data bag between the servlet and the JSP).

default package

Now comes the section were we check the other events occurred. The events come from:

The next methods called are:

Now the JSP is called and the data is displayed on your web browser.

dataAccess package

Bean

The bean serves as data bag. It has a string, a string array and two variables that define the length and width of the string array. All variables have get and set methods.

 

JSP

menu.jsp
The JSP gets the bean from the session context with the useBean command. It displays the the title and then uses the HTML grid (<td>, <tr> ...) to format the data in the bean. It uses a table view to display the persisted data. The table view has an input filed in the first row to change the quantity of the item.

add.jsp
JSP with input fields to enter a new product. There are two buttons, "Add" to add the entry and"Cancel" to go back to menu.jsp without adding the entry.

query.jsp
JSP with an input fields to define a filter string. The a filter string is applied to the "product ID". If you enter "0" as filter string, only products with a product ID that starts with "0" are displayed in menu.jsp. The query condition is made with the STARTSWITH option. If you leave the input field empty and choose "OK", all entries are displayed. When the "Cancel" button is clicked, the menu.jsp is displayed without any changes.

savefailed.jsp
If the saving of the new values fails the user informed with an error message in this JSP.