410 likes | 542 Views
VISUAL J++. Colorado Technical University IT420 Tim Peterson. J++ Advantages. There are many Rapid Application Development (RAD) environments for JAVA. Many work on only pure Java. J++ provides many features that can be utilized by Windows systems.
E N D
VISUAL J++ Colorado Technical University IT420 Tim Peterson
J++ Advantages • There are many Rapid Application Development (RAD) environments for JAVA. • Many work on only pure Java. • J++ provides many features that can be utilized by Windows systems. • J++ is an excellent tool for accessing databases.
J++ Overview • J++ is compatible with SUN’s Java Development Kit (JDK). • J++ includes Windows Foundation Classes (WFC). • J++ does not support Java Foundation Classes, Java Beans, or Enterprise Java Beans.
J++ Overview - Cont’d • Visual J++ allows users to use DHTML. • Visual J++ includes many wizards to help you with development efforts. • J++ is targeted towards people building Windows based corporate intranets. • J++ is OOP which makes it better than languages such as Vbasic.
Windows Foundation Classes • WFC is used integrate the Windows platform with the Java language. • Reasons to use WFC: • Performance is greatly increased. • WFC has a data binding model. • WFC also supports ADO and binds them. • If we were to implement our Java code on other platforms, we would not use WFC.
WFC Implementation • WFC is implemented as a Java class layer. • WFC provides an object oriented set of classes. • WFC allows for URL requests that in turn contain database connectivity. • With WFC, you can return HTML to a range of platforms including Windows CE devices, Web TV, and Macintosh.
WFC Implementation - Cont’d • WFC allows a developer to use any method (member function) contained within a DLL. • WFC applications will not run on non-windows platforms.’ • J++ provides an alternative to using Visual Basic and C++.
Component Object Model (COM) • COM is an integral part of developing Windows-specific intranet applications. • In J++, all Java objects become COM objects. • Key elements of the WFC API include: • UI based on either Win32 or DHTML • Data binding to a database. • Operations can be performed when connected to the Internet or in an off-line mode. • DOS command line operation.
WFC Packages • The main packages provided in WFC are as follows: • com.ms.wfc.app com.ms.wfc.io • com.ms.wfc.ax com.ms.wfc.ole32 • com.ms.wfc.core com.ms.wfc.ui • com.ms.wfc.data com.ms.wfc.util • com.ms.wfc. html com.ms.wfc.win32
GUI Classes • GUI classes from package wfc.ui provide: • Provides for control of GUI objects. Examples: • Setting and retrieving control properties. • Event management of controls. • Methods dealing with parent/child relationships of controls. • Methods affecting control layouts. • Low level control processing. • Windows handles, messages, and thread invocation.
System Classes • Part of wfc.app. • With WFC, one can manipulate the OS. • The developer can encapsulate memory and file objects. • Underlying OS platform can be accessed using J/Direct.
UI/DHTML Code Example Import wfc.ui.* { Form queryForm = new Form(); Button submit = new Button(); submit.setText (“Submit”) submit.setPosition(20,50); queryForm.add(submit); } • Import wfc.html.* • { • DhPanel queryForm = new DhPanel(); • DhButton submit = new DhButton(); • submit.setText (“Submit”) • submit.setPosition(20,50); • queryForm.add(submit); • }
DHTML Advantages • Allows you to create cross-platform code. • It provides for user interaction and data presentation using the following combinations: • HTML • Scripts • Document Object Model
DHTML Advantages - Cont’d • Allows the developer to control the Web Page. • DHTML pages can be authored using J++. • J++ then generates DHTML code on the fly. • To use DHTML in J++, you must extend the DhModule class.
Example J++ Extending DHTM Public class NewDHTMLClass extends DhModule { public void documentLoad(Object sender, DHEvent e) { DhDocument Dhdoc = getDocument(); Dhdoc.add(new DhText(“Text to see in Web page”)); } }
DHTML Event Handling • You work with events using delegates. • A delegate declaration extends .com.ms.lang.Delegate. • A delegate instance can call a method on an object and pass data to that method. • Mainly used to bind events to handler methods.
WFC Designer • WFC Designer tool is best way to build Windows GUIs using J++. • With this tool, you can bind data sources to any visual control using drag and drop. • Applications built using WFC designer are true Windows applications.
WFC Designer - Cont’d • In general, when using the WFC designer, the following should be accomplished: • Ensure that data controls are added to the toolbox. • Retrieve a set of records • Display the data on the form • Navigate the records. • If the above can be done, the integrity of the WFC is most likely sound.
DataSource Control • In the WFC designer, the DataSource control provides for data access for J++. • DataSource combines the functionality of Connection, Command, and Recordset objects. • DataSource only retrieves data and does not display it. • To being using DataSource, it must be added to a form.
DataSource Control - Cont’d • To connect to a database, you must set the connectionString property. To access an ODBC data source, the string is as follows: DSN=Nwind; UID=peterson; PWD=password • To access an Access database, the string is as follows: Provider=Microsoft.Jet.OLEDB.3.51; Data Source=filename; User ID=UserID; Password=password; • After this, then the SQL command is entered.
DataBinder Control • Now that the records have been retrieved, the data must be bound to a display. • If an attempt is made to updated a read-only recordset, and ADO exception is generated. • The DataBinder can only bind components that exist on the same WFC design surface. • DataBinder does not provide any means to validate changes made to a property’s value.
DataBinder Control - Cont’d • Components of bound properties can provide events. • To support a property change request, a <PropertyName>Changing event exists.
Universal Data Access • UDA is Microsoft’s solution to providing high-performance access to data. • UDA enables access to any data source on any platform. • An API is included for this. • Components that make this possible are ADO, Remote Data Services, OLE DB, and ODBC.
Java ActiveX Data Objects • JADO builds on ADO to present a simplified API. • JADO components include: • Connection objects • Command objects • Recordset objects • Purpose of JADO is to provide access to, to edit, and to update data sources.
JADO Abilities • Establish a connection to a data source. • Create an object. • Parameterize SQL statements with variable parameters using the Parameter object. • Execute the commands using the Connection, Command, or Recordset object.
JADO Abilities - Cont’d • Edit Recordsets. • Cache returned rows using a Recordset object. • Update data source with cached data. • Sort, filter, and navigate data in cache. • Commit and rollback changes and then end the connection using the Connection object.
Connection Object • Connection object is an open connection to a data source. • JADO accesses data and services from an OLE DB provider. • The connection object specifies: • the particular provider • associated parameters
Connection Object Open and Close Methods • The Open method establishes a physical connection to the data source. • Once live, you can issue commands against it. • The Close method is used to close a connection or free associated system resources. • Closing an object does not remove it from memory.
Connection Object Transactions • Transactions delimit the beginning and end of data access operations across a connection. • JADO ensures that transaction is totally complete prior to issuing a Commit. • If transaction is not completed, JADO issues a rollback.
Command Object • Command object is the definition of the command to run against a data source. • Commands normally add, delete, update, or retrieve data in a data source. • JADO optimizes the execution of the command. • With the Command object, multiple commands can be associated with a single object.
Parameter Object • This object allows you to treat parameters like functions. • All you need to know is this interface and how to pass to it. • This is used with the command object. • Use the CreateParameter method to create objects and use Append to add them to the Parameters collection.
Recordset Object • A recordset object reflects data from a row-returning query. • This object represents the set of records from a table or results from an executed command. • Recordset is used to examine and update data.
Recordset Object Capabilities • Recordset Objects perform the following: • Manage state of the Recordset. • Add, update, and delete rows • Traverse rows • Specify available rows • Specify order of rows • Update the data source with changes to rows.
Recordset Object Cursors • Recordsets are created using rows and columns. • JADO provides for four cursor types: • Dynamic • Keyset • Static • Forward-only • CursorType property must be set prior to opening the Recordset.
Field Object • To modify data in a data source, the Field objects are first modified. • Field objects can perform: • Get or set data in Field with Value Property. • Get the name of the field (Name Property). • Get attributes (Type, Precision, and Numeric scale).
Field Object - Cont’d • Obtain size of a field with DefinedSize and ActualSize properties. • Manipulate binary and char files with AppendChunk and GetChunk. • Determine functionality of a field by using the attributes property. • The value property of a field is handled as a variant.
Error Object • Errors with JADO usually are: • Failure to establish a connection. • Failure to execute a command. • Failure to perform an operation on an object in a suitable state. • Errors are placed in the Errors collection of the Connection object.
Error Object Properties • The Error object allows you to use the following properties: • Description • Number • Source • HelpFile and HelpContext • SQL State and NativeError
Collections • Under JADO, Collections exist for: • Parameter Objects • Field Objects • Error Objects • Data is retrieved using the collection method by name, text string, or integer number referencing it’s position in the collection.
Using Recordsets Remotely • JADO also provides the ability to develop off-network. • Users can download Remoteable Recordsets (a subset of the source data). • Developers can then create code to modify this Recordset off-line.
Visual Database Tools • Data View - used to connect to any ODBC or OLE DB database. • Database Designer - used to create and modify SQL server databases. • Query Designer - used to design, execute, and save SQL queries. • Stored Procedure Editor - Used to create STPs. • Stored Procedure Debugger - Used to debug STPs.