Network Deployment (Distributed operating systems), v8.0 > Reference > Developer detailed usage information
JDBC mediator integration with presentation layer
The JDBC Data Mediator Service (DMS) can be used in conjunction with web application presentation layer technologies such as JavaServer Pages Standard Tag Library (JSTL) and JavaServer Faces (JSF).
This discussion assumes a general understanding of both of the JSP Standard Tag Library (JSTL) and JavaServer Faces (JSF) technologies. In particular for JSF, the UIData component and the general file structure of a JSF dynamic web application should be known. For a brief overview of both JSF and JSTL refer to the topics under Service Data Objects.
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 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 the topic Example: Using JavaServer Faces and JDBC Mediator dataTables.
Example: Using JavaServer Faces and JDBC Mediator dataTables.
This example shows code that would be located inside of a Faces JSP page. It demonstrates how to use JavaServer Faces and JDBC Mediator dataTables in an application.
It contains the UIData component dataTable tag with all of the customer's information, along with their orders. Each Customer attribute has its own column. The Customer Orders are embedded in another dataTable containing each of the Order attributes in separate columns. This embedded dataTable of Orders is like any other Customer attribute, having its own column inside each Customer row.
<h:dataTable id="table1" value=">{pc_Customers.customer}" var= "varcustomer" styleClass="dataTable"> <h:column id="column1"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Customerid" id= "text1"> </h:outputText> </f:facet> <h:outputText id="text2" value=">{varcustomer.CUSTOMERID}" styleClass="outputText"> <f:convertNumber /> </h:outputText> </h:column> <h:column id="column2"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Custfirstname" id="text3"> </h:outputText> </f:facet> <h:outputText id="text4" value=">{varcustomer.CUSTFIRSTNAME}" styleClass="outputText"> </h:outputText> </h:column> <h:column id="column3"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Custlastname" id="text5"> </h:outputText> </f:facet> <h:outputText id="text6" value=">{varcustomer.CUSTLASTNAME}" styleClass="outputText"> </h:outputText> </h:column> <h:column id="column4"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Custstreetaddress" id="text7"> </h:outputText> </f:facet> <h:outputText id="text8" value=">{varcustomer.CUSTSTREETADDRESS}" styleClass="outputText"> </h:outputText> </h:column> <h:column id="column5"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Custcity" id="text9"> </h:outputText> </f:facet> <h:outputText id="text10" value=">{varcustomer.CUSTCITY}" styleClass="outputText"> </h:outputText> </h:column> <h:column id="column6"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Custstate" id= "text11"> </h:outputText> </f:facet> <h:outputText id="text12" value=">{varcustomer.CUSTSTATE}" styleClass="outputText"> </h:outputText> </h:column> <h:column id="column7"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Custzipcode" id="text13"> </h:outputText> </f:facet> <h:outputText id="text14" value=">{varcustomer.CUSTZIPCODE}" styleClass="outputText"> </h:outputText> </h:column> <h:column id="column8"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Custareacode" id="text15"> </h:outputText> </f:facet> <h:outputText id="text16" value=">{varcustomer.CUSTAREACODE}" styleClass="outputText"> <f:convertNumber /> </h:outputText> </h:column> <h:column id="column9"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Custphonenumber" id="text17"> </h:outputText> </f:facet> <h:outputText id="text18" value=">{varcustomer.CUSTPHONENUMBER}" styleClass="outputText"> </h:outputText> </h:column> <h:column id="column10"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Customers_orders" id="text19"> </h:outputText> </f:facet> <h:dataTable id="table2" value=">{varcustomer.CUSTOMERS_ORDERS}" var="varCUSTOMERS_ORDERS" styleClass="dataTable"> <h:column id="column11"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Ordernumber" id="text20"> </h:outputText> </f:facet> <h:outputText id="text21" value=">{varCUSTOMERS_ORDERS.ORDERNUMBER}" styleClass="outputText"> <f:convertNumber /> </h:outputText> </h:column> <h:column id="column12"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Orderdate" id="text22"> </h:outputText> </f:facet> <h:outputText id="text23" value=">{varCUSTOMERS_ORDERS.ORDERDATE}" styleClass="outputText"> <f:convertDateTime /> </h:outputText> </h:column> <h:column id="column13"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Shipdate" id="text24"> </h:outputText> </f:facet> <h:outputText id="text25" value=">{varCUSTOMERS_ORDERS.SHIPDATE}" styleClass="outputText"> <f:convertDateTime /> </h:outputText> </h:column> <h:column id="column14"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Customerid" id="text26"> </h:outputText> </f:facet> <h:outputText id="text27" value=">{varCUSTOMERS_ORDERS.CUSTOMERID}" styleClass="outputText"> <f:convertNumber /> </h:outputText> </h:column> <h:column id="column15"> <f:facet name="header"> <h:outputText styleClass="outputText" value="Employeeid" id="text28"> </h:outputText> </f:facet> <h:outputText id="text29" value=">{varCUSTOMERS_ORDERS.EMPLOYEEID}" styleClass="outputText"> <f:convertNumber /> </h:outputText> </h:column> </h:dataTable> </h:column> </h:dataTable>