Refine the web application
Now that the client has been set up to talk to the servlet, it's necessary to add more functionality to the servlet.
- Switch to the Simplicity Enterprise Composer.
- Choose "Start PointBase Demonstration Server..." from the Program menu.
- After the database server has been started, switch to the JDBC tab of the Simplicity Enterprise Module Palette.
- Drag a Connection to the Modules node of the tree, beneath the Form module you added earlier. A new item named JDBCConnection will be created.
- The connection you just made, JDBCConnection, has a subnode named Properties. Select this node and press the Connect button at the bottom. This will connect to the PointBase server which you just started.
- Next drag a Statement from the JDBC tab of the Palette to the Modules, just below the Connection you just created.
- On the Properties node of the SQLStatement which was just created, be sure that 'jDBCConnection', the connection you made, is selected. This will tell Simplicity to run the statement with that connection.
This servlet will perform queries of the Product Table.
- Select the SQL Query Builder node of SQLStatement, and press the Code Sourcerer button. The Code Sourcerer will lead you through the task of building an SQL Query.
- Choose the first item, 'Search for rows from a database table'. Press Next.
- You must now choose the table to work with. Expand the "Public" node, and scroll down to "PRODUCT_TBL". Press Next.
- Now a list of the columns of the table will appear. Since mobile devices often do not have fast connections, you want to return the minimum data required. For this application, choose the 'Choose Columns' Option. Then select the "DESCRIPTION", "PURCHASE_COST", and "QTY_ON_HAND" columns from the list. Press Next.
- The next page lets you refine your search. For this query, choose "Description" from the popup list on the left, "contains" from the list in the middle, and type the word "cable" into the list on the bottom right. Uncheck the box which says 'Search is case sensitive'. The query will look like
UPPER(DESCRIPTION) LIKE '%' || UPPER('cable') || '%'
Press Done.- A few lines of SQL code will be produced. Test the code by pressing "Execute Query". You will see two results in the area below the query.
- Next drag a Table module from the JDBC tab of the Palette to the Modules, below the SQLStatement. This module will make it easy to export the results of the query.
- On the Properties node of the ResultTable which was just created, select 'SQLStatement' if it is not already selected. This will link the table with the statement which was created.
Now the servlet needs a way to send this data to the client. The way to do this is with an XMLExporter module.
- Select the XML tab of the Palette.
- Drag an XML Exporter into the Modules list, below the ResultTable.
- On the Properties node of the XMLExport node, choose 'resultTable_tableData' to send the table of results to the client.
You now have a servlet which is much more functional than before. It will return the results of a search, in table format, each time it's run. It's time to go back to the MIDlet client and allow it to take advantage of this information.
| Data Representations, Inc. http://www.datarepresentations.com support@datarepresentations.com sales@datarepresentations.com |