Duncan Mills

Download Report

Transcript Duncan Mills

How to Leverage Java
in Oracle Forms Web
Applications
Duncan Mills
Application Development Tools
Oracle Corporation
Agenda
 Java in the Database
 Extending the Web Client with Java
 Calling Java on the Middle tier
 Putting it All Together
Java in the Database
 It’s just a Stored Procedure Right?
Agenda
 Java in the Database
 Extending the Web Client with Java
 Calling Java on the Middle Tier
 Putting it All Together
Extending the Web Client
 Pluggable Java Components (PJC)
–
Subclass and extend an existing Items type
–
Create a brand new (possibly complex)
widget based on a bean
 PJCs may be headless e.g.
–
ClientInfo Bean
Java Bean
Radio Buttons
Checkboxes:
Y
N
Disabled
Cash
Credit Card
Cheque
Pluggable Java Components Architecture
IAS
Forms Services
Browser JVM
Client Manager
Engine
Handler
View
Handler
View
Handler
View
The Handler Class
 Receives messages from Forms Server for
describing properties and state
 Sends messages to Forms Server to notify
application of user interactions
 Maintains data values
 Manages the corresponding View Object
 Represents a specific item type
 Has no visual representation
 Implements oracle.forms.handler.IHandler
The View Class
 Provides the visual representation of the
UI component and data
 Is managed by a corresponding Handler
Object
 Allows user to interact with it and notifies
it’s Handler Object of any user interaction
 Represents a specific item type
 Implements oracle.forms.ui.IView
Pluggable Java Components
Architecture
Client Manager
Oracle Developer Server
Engine
Handler
View
Published Interface
Handler
View
Handler
View
Handler
View
Pluggable Java Components
Architecture
Client Manager
Oracle Developer Server
Engine
Handler
Handler
View
Handler
View
Handler
MyView
View
View
Cash
Credit Card
Cheque
The IView Interface
 init
–
called by handler to set-up object
 destroy
–
called by handler when object no longer
required
 getProperty / setProperty
 addListener / removeListener
D E M O N S T R A T I O N
Creating a PJC
The PJC Problem….
 They are linked to the UI not the Data
 SET/GET_CUSTOM_PROPERTY()
–
Takes a ROW number (or ALL_ROWS)
–
This is the UI Row Number NOT the Data Row
 Only a issue when:
–
Multi-row block
–
UI is linked to the data in some way
JavaBeans Need More Work..
 Wrapper / “Bridging” code required to
interface IView with JavaBean
Handler
JavaBean
setProperty(BACKGROUND,…)  setBackgroundColor()
D E M O N S T R A T I O N
JavaBean Example
Enhanced Bean Support in Forms 9i
 No need to write Java wrapper!
 Assign the bean class at runtime
 Register the events you want to listen for
from PL/SQL
 Forms uses introspection to find out
what methods and properties are
available
 New Built-in Package – FBEAN
 Also manages heavyweight
Beans
D E M O N S T R A T I O N
Bean with no
Wrapper
Agenda
 Java in the Database
 Extending the Web Client with Java
 Calling Java on the Middle Tier
 Putting it All Together
Java – Your Gateway to a World of
Functionality
Web Services
EJB
SOAP
JavaMail
Java Utilities
Corba
Custom Java
XML
Calling Java on the Middle Tier
 Java Importer Feature
–
Introduced with 6i Release 2
–
Available for both Web & Client Server
–
Use 1.2+ JDK
 ORA_JAVA package implements a JNI
bridge
–
PL/SQL  C JAVA
What the Importer Does...
 Scans CLASSPATH
for available
classes
 One PL/SQL
package per Class
 Options
Mapping Java into PL/SQL
 Constructors map to NEW() function(s)
–
return JOBJECT
 All mapped methods take this JOBJECT
–
(Unless STATIC)
 By default JOBJECTs persist as long as
the Current Program Unit/Trigger
–
NEW_GLOBAL_REF
–
DELETE_GLOBAL_REF
Example
declare
-- Declare a var to hold the object
tokenizer ORA_JAVA.JOBJECT;
begin
-- Create an instance of a StringTokenizer
-- Supplying the input String to use
tokenizer := StringTokenizer.new(:source,',');
-- Use the Tokenizer
while StringTokenizer.hasMoreTokens(tokenizer) LOOP
-- Split each token onto it's own line
:output := :output||
StringTokenizer.nextToken(tokenizer)||
chr(10);
end LOOP;
-- No need to explicitly destroy the object
end;
Handling Errors
 PL/SQL Exception
ORA_JAVA.EXCEPTION_THROWN
 Exception JOBJECT passed in
ORA_JAVA.LAST_EXCEPTION
 Remember to import your Exception
object!
 Clean up
ORA_JAVA.CLEAR_EXCEPTION
D E M O N S T R A T I O N
Using the Importer
Agenda
 Java in the Database
 Extending the Web Client with Java
 Calling Java on the Middle Tier
 Putting it All Together
Putting it all Together
 Predefined Samples and Demos
 A Real World Example!
Predefined Samples
 On 6i Demos CD
URL:
–
Calendar
–
Progress Bar
–
Rounded Button
–
HTML Viewer
–
Text Item as Prompt
 On Oracle
Technology
Network
–
Hyperlink Bean
–
GetClientInfo
–
Knob Control
–
Digital Clock
–
Rollover Button
–
Key Filter
–
Mouse Cursor modifier
http://otn.oracle.com/products/forms
A Real Example - File Upload!
Browser
Client
Bean
oracle.forms.demos.FileUploader
1) Display File Dialog
2) Zip the selected File
3) Encode to Base64
4) Chop up onto 4k Chunks
5) Transfer Chunks
Server
When-Custom
-Item-Event
Imported Class
oracle.forms.demos.FileDecoder
1) Assemble file chunks
2) Decode from Base64
3) Unzip
4) Write the file
D E M O N S T R A T I O N
File Upload in
Action
Q U E S T I O N S
A N S W E R S