Running the JClient Component Bindings Demo

An Oracle JDeveloper Sample
October 2002

Content

Introduction
Installing and Running the Demo
Using this JClient Demo
The Data Model Used in the JClient Binding Demo
Using Lazy Loading to Delay Executing View Queries
Sharing a JClient Panel Binding to Synchronize View Data
Reusing Components to Assemble the Java Application
Summary

Introduction

This JClient component demo illustrates the complete set of component bindings available with JClient. JDeveloper helps you set JClient component bindings on standard Swing components to quickly assemble databound applications. With a Business Components for Java (BC4J) middle tier in place to represent application-specific views of the data, your Java client UI can use JClient bindings and standard Swing components to create a rich, interactive experience for the end user.

Installing and Running the Demo

To create the schema for the demo:
  1. Create a user:
    • Log in to the database administrator account using SQL*Plus:
      SQL> create user name identified by password;
      SQL> grant resource, create session, connect to username;
  2. Create the tables:
    • Change directory to <JDeveloper_Home>/BC4J/samples/JClientWorkspace.
    • Log into SQL*Plus as your newly created user and create the tables using the following command:

    • SQL> @createJClientDemoTables.sql
  3. Create a database user in JDeveloper:
    • Right-click the Connections->Database tree node and choose New Connection. This will launch a wizard that you must complete.
  4. Update the design-time connection in your BC4J project.:
    • In the Navigator, expand the onlineorders package in the Business Components folder in the OnlineOrders.jpr project.
    • Right-click OnlineOrdersModule and choose Configurations... .
    • Click Edit in the Configuration Manager to update the existing OnlineOrdersModuleLocal configuration definition.
    • In the Navigator, at the bottom of the onlineorders package, right-click OnlineOrders.jpx and and choose Edit OnlineOrders... .
    • On the Connection tab of the Business Components Project dialog, select the newly created connection from the Connection Name menu.
  5. Compile the BC4J project.
You are now ready to configure the JClient project (named ComponentDemo.jpr). In JDeveloper's Navigator, view the project in Package View mode; your Navigator should look like this:


If this image does not correspond with what you see, select ComponentDemo.jpr and click the Show Categories button above the Navigator (the inverted button in the above image).

To configure the JClient project:

  1. Synchronize the JClient libraries with the BC4J configuration definition:
    • Select ComponentDemo.cpx.
    • In the Structure Window (choose View->Structure Window) you will now see a JClient Data Definition named ComponentDemoModule.
    • Right-click this node and choose Modify Client Application Model... .
    • Complete the wizard and select the Finish button.

      You just updated the Client libraries in this project.

  2. Test the JClient Data Definition.
    • In the Navigator, expand the test package to locate the class named testApplicationDefinition.java.
    • Run this test case to verify your data definition. It will try to connect and tell you if you succeeded by popping up a window.
    • To terminate the process, in JDeveloper choose Run->Terminate->ComponentDemo.jpr.

  3. Load the demo images:
    • In the mediaLoader package, you'll find a class named loadMedia.java.
    • Run this class, to load the images into the database.

  4. Modify the program arguments:
    • Right-click Componentdemo.jpr and choose Project Settings... .
    • Choose Runner in the Project Settings dialog selection tree.


    • Modify Program Arguments so they point to the directory containing all your source files.
To run the JClient demo:

You are now ready to run the demo. The starting class is componentdemo.StartFrame.java.

Using this JClient Demo

JDeveloper provides a range of JClient bindings from which you can select to implement component-specific behavior such as navigating the rowset, displaying attribute values, and providing user-selection lists. This JClient demo lets you test drive the JClient bindings to visualize the component-specific behaviors of each binding.

Three steps to explore a JClient binding:

  1. Choose the desired Swing component from the button bar. Read the name of the selected demo below the button bar (for example, "JButton binding demo"). If the label displays more then one component name, the bindings correspond to a family of components, which have similar behavior and thus can make use of the same bindings.

  2.  

  3. Choose the tab which corresponds to the JClient binding you want to explore. In many cases, the demo displays more than one tabbed panel per Swing component or multiple components, which reuse the same bindings. This is necessary because JClient often provides multiple ways to interact with the data.

  4.  

  5. Click Alt+F1 to display the Help page and source code for the current demo. The help page describes the behavior of the current JClient binding demo and gives instructions for interacting with the the middle tier data using the JClient binding.
Below is the window you see when you start up the demo:

 


About the Demo Window:
 
Window Area Description
Menu Bar Use the menus to display a Help page and source code for each demo. The Help page gives instructions for using the currently displayed demo.
Button Bar Use the button bar to choose the Swing component for which you want to explore available JClient component bindings. You may tab through the button bar.
Info Label The info label lists a single component or in some cases multiple components that comprise a component family, which reuses the same bindings. In the case of the component families, the tabbed panel may not display an example of each component; however, the component binding of another family member lets you explore the behavior of the JClient binding for this family of components.
Tabs Choose a tab to view a specific JClient binding type for the family of components. There will be one tab for each binding.
Demo Panel Interact with the demo panel to explore a specific JClient binding example for the family of components. Use the menu at any time to read a description of the active demo panel and display it side by side with the source code for this example. You can tab through the displayed components.
Status Bar View the JClient status bar to get information about the state of the current RowSet used to populate the demo. This status bar can help you to understand the workings of JClient bindings.

 

The Data Model Used in the JClient Binding Demo

A JClient application works requires a Business Component for Java (BC4J) middle tier to access the data and populate the UI. JDeveloper provides BC4J application wizards that let you generate the middle tier and define the data model for your Java client.

This JClient demo uses the following BC4J data model, which queries the database through Customers, Orders, and InventoryItems view objects:


This particular data model defines a Master-Detail-Detail relationship:

  • Customers ( placing ) Orders.  Orders (consisting of) LineItems.
  • The LineItemViewPlus is a join, which joins LineItems with some extra fields from InventoryItem.
  • The CustomerstatusView is another lookup table containing the 3 possible statuses a customer can have (Platinum, Gold, Silver).
  • The StatesView is a lookup table, containing all the 50 states and their abbreviations.
  • VideoDemoView is a view to complex OrdVideoDomain objects and arrays of VideoMarks to playback the videos.
  • The ScalesView is a view to OrdVideoDomain objects to display images of the scales and OrdAudioDomain objects to playback audio for each scale.

Using Lazy Loading to Delay Executing View Queries

This JClient demo uses lazy loading of the queries. Lazy loading provides an efficient way to execute queries because the application only retrieves the data needed to display the current panel.

In this JClient demo, a panel is initialized only when you wish to see the panel; the panels' default constructors do not handle populating the display. Instead, the default constructor is used to get an empty panel, which allows the panel to be added to the demo's TabbedPane. When you choose a tab to display a demo Panel, only then is the setPanelBinding() method on the demo panel called. This method instantiates all fields and binds them to the appropriate view objects in the middle tier.

Sharing a JClient Panel Binding to Synchronize View Data

Panel binding is the JClient mechanism for synchronizing RowSet Iterators across panels of the same frame. In this JClient demo, all the panels share a single panel binding object (the default behavior). This means that when you display a demo panel, you might begin stepping through the Customer table and while doing so decide to look at another part of the demo that also uses the Customer table. Because both panels share the same panel binding object, their RowSet Iterators will be synchronized and therefore the data displayed will be consistent between panels. This behavior is provided by the JClient panel binding object with no additional coding by you required.

Reusing Components to Assemble the Java Application

Good design encourages reuse of components and any JClient application should follow this principle too. In this JClient demo, the entire application is constructed from just a few panels which get reused throughout. You can see the benefits of component reuse by examining the reduced amount of code in the panels for the Tree and Navigation Bar demos. JDeveloper helps you to enforce component reuse in the application code generated by the JClient-specific wizards.

Summary

This demo provides many examples with documented source code that can help you to create your own reusable data bound panels to assemble a JClient UI for use with a Business Components project.
E-mail this page
Printer View Printer View
Oracle Is The Information Company About Oracle | Oracle RSS Feeds | Careers | Contact Us | Site Maps | Legal Notices | Terms of Use | Privacy