# ItemsDBControl.jcx Sample

This topic inludes the source code for the ItemsDBControl.jcx Sample.

## Sample Location

This sample is located in the following directory in your WebLogic Workshop installation:

BEA_HOME/weblogic81/samples/workshop/SamplesApp/WebApp/handlingData/dropdown/

## Sample Source Code

`001 package handlingData.dropdown; 002 003 import java.sql.SQLException; 004 import javax.sql.RowSet; 005 006 import com.bea.control.DatabaseControl; 007 import weblogic.jws.control.DatabaseFilter; 008 009 /** 010 *@jc:connection data-source-jndi-name="cgSampleDataSource" 011 *@common:schema file="#rowset-schemas" inline="true" 012 *@common:define name="rowset-schemas" value:: 013 * <xsd:schema targetNamespace="http://www.tempuri.org" xmlns="http://www.tempuri.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:wld="http://www.bea.com/2002/10/weblogicdata" elementFormDefault="qualified" attributeFormDefault="qualified" id="ITEMSRowSet" > 014 * <xsd:element wld:DefaultNamespace="http://www.tempuri.org" name="ITEMSRowSet" wld:RowSet="true" wld:WriteTable="ITEMS" > 015 * <xsd:complexType> 016 * <xsd:choice maxOccurs="unbounded" > 017 * <xsd:element name="ITEMSRow" > 018 * <xsd:complexType> 019 * <xsd:sequence> 020 * <xsd:element name="ITEMNUMBER" wld:AutoIncrement="true" type="xsd:int" wld:readOnly="true" wld:PrimaryKey="true" wld:JDBCType="INTEGER" minOccurs="0" wld:TableName="ITEMS" /> 021 * <xsd:element name="ITEMNAME" wld:AutoIncrement="false" type="xsd:string" wld:readOnly="false" wld:PrimaryKey="false" wld:JDBCType="VARCHAR" minOccurs="0" wld:TableName="ITEMS" /> 022 * <xsd:element name="QUANTITYAVAILABLE" wld:AutoIncrement="false" type="xsd:int" wld:readOnly="false" wld:PrimaryKey="false" wld:JDBCType="INTEGER" minOccurs="0" wld:TableName="ITEMS" /> 023 * <xsd:element name="PRICE" wld:AutoIncrement="false" type="xsd:decimal" wld:readOnly="false" wld:PrimaryKey="false" wld:JDBCType="DOUBLE" minOccurs="0" wld:TableName="ITEMS" /> 024 * </xsd:sequence> 025 * <xsd:anyAttribute namespace="http://www.bea.com/2202/10/weblogicdata" processContents="skip" /> 026 * </xsd:complexType> 027 * </xsd:element> 028 * </xsd:choice> 029 * </xsd:complexType> 030 * </xsd:element> 031 * </xsd:schema>:: 032 */ 033 public interface ItemsDBControl extends com.bea.control.ControlExtension, DatabaseControl 034 { 035 /** 036 * @jc:sql command-type="grid" 037 * rowset-name="ITEMSRowSet" 038 * statement:: 039 * SELECT ITEMNUMBER,ITEMNAME,QUANTITYAVAILABLE,PRICE FROM ITEMS 040 * {sql: filter.getWhereClause ()} 041 * {sql: filter.getOrderByClause ()} 042 * :: 043 */ 044 public RowSet getAllItems ( DatabaseFilter filter ) 045 throws SQLException; 046 047 /** 048 * @jc:sql command-type="detail" 049 * rowset-name="ITEMSRowSet" 050 * statement:: 051 * SELECT ITEMNUMBER,ITEMNAME,QUANTITYAVAILABLE,PRICE FROM ITEMS WHERE ITEMNUMBER = {x} 052 * :: 053 */ 054 public RowSet getItems ( Integer x ) 055 throws SQLException; 056 057 /** 058 * @jc:sql command-type="update" 059 * rowset-name="ITEMSRowSet" 060 */ 061 public RowSet updateItems ( RowSet changedRs ) 062 throws SQLException; 063 064 /** 065 * @jc:sql command-type="delete" 066 * rowset-name="ITEMSRowSet" 067 */ 068 public void deleteItems ( RowSet oldRs ) 069 throws SQLException; 070 071 /** 072 * @jc:sql command-type="templateRow" 073 * rowset-name="ITEMSRowSet" 074 */ 075 public RowSet getItemsTemplate () 076 throws SQLException; 077 078 /** 079 * @jc:sql command-type="insert" 080 * rowset-name="ITEMSRowSet" 081 */ 082 public void insertItems ( RowSet changedRs ) 083 throws SQLException; 084 085 /** 086 * @jc:sql command-type="insertedRow" 087 * rowset-name="ITEMSRowSet" 088 * statement:: 089 * SELECT ITEMNUMBER,ITEMNAME,QUANTITYAVAILABLE,PRICE FROM ITEMS WHERE ITEMNUMBER = ( Select Max ( ITEMNUMBER ) From ITEMS) 090 * :: 091 */ 092 public RowSet getInsertedItems () 093 throws SQLException; 094 095 096 /** 097 * @jc:sql statement:: 098 * SELECT ITEMNAME,ITEMNUMBER,QUANTITYAVAILABLE,PRICE FROM ITEMS ORDER BY ITEMNAME 099 * :: 100 */ 101 public ItemSelectNode[] getItemSelectData() throws SQLException; 102 103 public static class ItemSelectNode 104 implements java.io.Serializable 105 { 106 public String itemName = null; 107 public int itemNumber = -1; 108 public int quantityAvailable = -1; 109 public double price = 0; 110 111 public ItemSelectNode() {} 112 113 public ItemSelectNode(String itemName, int itemNumber, int quantityAvailable, double price) 114 { 115 this.itemName = itemName; 116 this.itemNumber = itemNumber; 117 this.quantityAvailable = quantityAvailable; 118 this.price = price; 119 } 120 } 121 122 }`