Upload
neylan
View
25
Download
0
Tags:
Embed Size (px)
DESCRIPTION
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. - PowerPoint PPT Presentation
Citation preview
5-1
VISUAL J++
Colorado Technical University
IT420
Tim Peterson
5-2
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.
5-3
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.
5-4
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.
5-5
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.
5-6
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.
5-7
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++.
5-8
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.
5-9
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
5-10
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.
5-11
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.
5-12
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);
}
5-13
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
5-14
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.
5-15
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”));
}
}
5-16
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.
5-17
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.
5-18
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.
5-19
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.
5-20
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.
5-21
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.
5-22
DataBinder Control - Cont’d
• Components of bound properties can provide events.
• To support a property change request, a <PropertyName>Changing event exists.
5-23
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.
5-24
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.
5-25
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.
5-26
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.
5-27
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
5-28
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.
5-29
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.
5-30
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.
5-31
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.
5-32
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.
5-33
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.
5-34
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.
5-35
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).
5-36
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.
5-37
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.
5-38
Error Object Properties
• The Error object allows you to use the following properties:– Description– Number– Source– HelpFile and HelpContext – SQL State and NativeError
5-39
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.
5-40
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.
5-41
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.