CDataBaseList - custom component for displaying database query results.


A CDataBaseList is a component that displays the results of a database query via jdbc. By default the records are shown in a list with different colors for even and odd rows.

    // initialise the CDataBaseList like this.
    cDataBaseList1.setSQLStatement( new WebSQLStatement( "Select * from users" ) );
    cDataBaseList1.setConnection( webConnection1 );
    cDataBaseList1.setKeepColumnProperties( true );
    cDataBaseList1.setShowRowSelector( true );

The CDataBaseList component has the capability to keep the layout settings of the ColumnProperties while switching the SQL statement to another one. Keeping the ColumnProperties alive is only possible, if the new statement has the same field selections than the old one. The statement may differ e.g. in its 'where clause' for implementing search queries. To keep the ColumnProperties alive the keepColumnProperties attribute of the CDataBaseList must be set to true.

  // we have a button and a text on the panel for implementing a simple search mechanism
  private void doWebButton1WebActionPerformed( WebActionEvent e ) throws Exception {
    String question = webText1.getValue();
      new WebSQLStatement( "Select * from users where lastname like '" + question + "'" ) );

CDataBaseLists also has an predefined row selection, which is simply activated by adding a WebActionListener to the CDataBaseList instance and setting the showRowSelector attribute to true (see above). Clicking the row selection button of a destined row will trigger the listeners handler method:

  // the event handler method which is processed after the row selector button was pressed.
  private void doCDataBaseList1WebActionPerformed( WebActionEvent e ) throws Exception {
    // determine the seleted row
    int row = cDataBaseList1.getRow( e.getSourceComponent() );
    // read some values from the selected row
    String lastName = cDataBaseList1.getValue( row, 2 );
    String firstName = cDataBaseList1.getValue( row, 1 );
    // show a message made of the row values for demo purpose
      new Message( "The name is " + lastName + ", " + firstName + " " + lastName + "." ) );


CDataBaseList is based on the WebDataBaseTable component which is wrapped by a WebContainer with WebFlowLayout as layout manager. It is a convenience component which pre-sets some of the most common settings.

API documentation

The API documentation for CDataBaseList can be found here.