+

Search Tips   |   Advanced Search

JDBC mediator integration with presentation layer


The JDBC Data Mediator Service (DMS) can be used in conjunction with Web app presentation layer technologies such as JSPs Standard Tag Library (JSTL) and Java Server Faces (JSF).

This discussion assumes a general understanding of both of the Java Server Pages Standard Tag Library (JSTL) and Java Server Faces (JSF) technologies.

In particular for JSF, the UIData component and the general file structure of a JSF dynamic Web app should be known. For a brief overview of both JSF and JSTL refer to the links at Service Data Objects: Links.

The JDBC DMS and JSTL work well together because the JSTL access code is equivalent to the code necessary to access attributes and lists inside of a DataObject. For example, in relation to a root Customer DataObject, the JSTL expression:

${rootDO.CUSTOMER[index].CUSTNAME}
is equivalent to the Java code for a DataObject of:

rootDO.getList("CUSTOMER").get(index).get("CUSTNAME")
The reason for this is the dot notation in the JSTL expression language correlates to a getter() method in Java code, and the bracket notation allows you to access elements inside a list.

The JDBC DMS and JSF fit well together because the DataGraph produced by the JDBC DMS is able to populate a JSF UIData component without having to be transformed. The UIData component uses a dataTable tag that takes a list as its input to populate the table. This works out well with the DataGraph because all we need to pass into the dataTable is the root list of the DataGraph.

The most common way to lay out the DataGraph in the dataTable is to display each attribute of the DataObject from the list retrieved from the root in its own column, and to embed each additional relationship to the DataObject in a new dataTable contained within the parent DataObject’s row. Using this method instead of a traditional ResultSet table eliminates duplicate information and makes it easier to see the separation of the parent object’s children.

An example of how the Customer and Order scenario is laid out in a dataTable is shown in Example: Using Java Server Faces and JDBC Mediator dataTables



Subtopics


Example: Using Java Server Faces and JDBC Mediator dataTables