Top Banner
How to integrate APEX and Oracle Forms? Roel Hartman
26

Integration of APEX and Oracle Forms

Nov 22, 2014

Download

Technology

Roel Hartman

Presentation on how to Integrate the old and new Oracle technologies. Communicate from Forms to APEX and v.v.
(Demo movie at the end of the presentation)
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Integration of APEX and Oracle Forms

How to integrate APEX and Oracle Forms?

Roel Hartman

Page 2: Integration of APEX and Oracle Forms

Who am I?

Page 3: Integration of APEX and Oracle Forms

Who am I – somewhat more serious

roelhartman.blogspot.com

• Presenter at UKOUG (2x), OOW, ODTUG• APEX 3.2 EAR• OTN Forum• Articles• Blogger• Working for

Page 4: Integration of APEX and Oracle Forms

Introduction

APEX 3.2 : Forms conversion

The challenge of converting Simple Forms (60%) Moderate Forms (30%) (Very) Complex Forms (10%)

Top 10 %

projectstart

projectfinish

Page 5: Integration of APEX and Oracle Forms

The concept comes from…

OraFormsFaces

Thank you Wilfred!

Page 6: Integration of APEX and Oracle Forms

Embed a Form in APEX• Insert HTML• PL/SQL Procedure • URLhttp://localhost:7778/forms/frmservlet?config=apex&module=orders

Page 7: Integration of APEX and Oracle Forms

Embed a Form in APEX

Page 8: Integration of APEX and Oracle Forms

APEX PAGEAPEX REGION

Embed a Form in APEX

ORACLE FORM

Page 9: Integration of APEX and Oracle Forms

Visual Integration• Embed Forms HTML within two DIVs• Modify & Set• OuterDiv Width & Height• InnerDiv Width & Height• Applet Width & Height• Applet Margins• Address Applet by adding an

ID="formsapplet" line• Settings browser dependent

• Use same background color

<div id="outerdiv" style="overflow:hidden; border-style:none;"> <div id="innerdiv" style="overflow:scroll; border-style:none;"> #BODY# </div></div>

Page 10: Integration of APEX and Oracle Forms

Visual Integration

Page 11: Integration of APEX and Oracle Forms

Communicate from Forms to APEX• Use web.show_document( URL, target )• Attach a common library to your Form• Create procedure runJavascript

Requirement :When I move through a list of Products (Oracle Form), I want to see who bought it and where the customer is located.

web.show_document( ‘javascript:showOnMap()’, ‘_self’);PROCEDURE runJavascript( pScript varchar2) ISBEGIN web.show_document('javascript:'||pScript, '_self'); END;

Page 12: Integration of APEX and Oracle Forms

Communicate from Forms to APEX• Call procedure from WHEN-NEW-RECORD-

INSTANCE• Create procedure TriggerApex

TriggerApex('WHEN-NEW-RECORD-INSTANCE');PROCEDURE TriggerApex( pTrigger varchar2 ) ISBEGIN if name_in('system.current_form') = 'PRODUCTS' then if pTrigger = 'WHEN-NEW-RECORD-INSTANCE' then -- Requery APEX Reports region with parameter on Page 9 -- & Show the data on the Map runJavascript('refreshReport('|| name_in('PRODUCTS.PRODUCT_ID')|| ', ''P9_PRODUCT_ID'');showOnMap();'); end if; end if;END;

Page 13: Integration of APEX and Oracle Forms

Communicate from Forms to APEX

Page 14: Integration of APEX and Oracle Forms

Communicate from Forms to APEX

APEX PAGEAPEX REGION

ORACLE FORM

APEX REGIONAPEX Form

APEX Report

APEX Chart

web.show_document

Page 15: Integration of APEX and Oracle Forms

Communicate from APEX to Forms

Requirement :When I click on a customer in a report, I should be able to edit the customer data – using our current (very complex) Form. When I save the changes the report should be updated immediately.

Page 16: Integration of APEX and Oracle Forms

Communicate from APEX to Forms• Read Forms-as-Web-Components-Step-by-

Step.pdf• raiseEvent procedure – extend the Forms runtime

• CommunicatorBean – receive external events

• Add PJC to your Form

Page 17: Integration of APEX and Oracle Forms

Communicate from APEX to Forms• Define column link as : javascript:queryCustomer(#ID#);

• raiseEvent triggers (Bean’s) WHEN-CUSTOM-ITEM-EVENT• WHEN-CUSTOM-ITEM-EVENT calls execEvent• execEvent handles the request• Add code to TriggerApex procedure in library to refresh report

PROCEDURE execEvent IS BeanEventDetails ParamList; ParamType number := text_parameter; Event varchar2(1000); Payload varchar2(1000);begin BeanEventDetails := get_parameter_list(name_in('system.custom_item_event_parameters')); get_parameter_attr(BeanEventDetails, 'Event', ParamType, Event); get_parameter_attr(BeanEventDetails, 'Payload', ParamType, Payload); if name_in('system.current_form') = 'CUSTOMERS' then if upper(event)='EXECUTE_QUERY' then set_block_property('DEMO_CUSTOMERS' , DEFAULT_WHERE, 'WHERE CUSTOMER_ID = '||payload ); execute_query; end if; end if;end;

function queryCustomer( pCustId ){ //Setting Customer Id in Form and Requery execFormAction( 'execute_query', pCustId)}function execFormAction(pAction, pParam){ //Raising an event in Forms //Execute the Action (like 'execute query') $x('formsapplet').raiseEvent(pAction, pParam );}

if pTrigger = 'POST-DATABASE-COMMIT‘then -- Requery APEX Reports region with pValue, pField parameters runJavascript('refreshReport('''', '''')');end if;

Page 18: Integration of APEX and Oracle Forms

Communicate from APEX to Forms

APEX PAGEAPEX REGION

ORACLE FORM

APEX REGIONAPEX Form

APEX Report

APEX Chart

web.show_document

PJC

APEX REGION

Extended Forms Applet : raiseEvent

CommunicatorBean / PJC

WHEN-CUSTOM-ITEM-EVENT

Library

Page 19: Integration of APEX and Oracle Forms

Using the Applet Life Cycle• Prevent multiple frmweb processes• HTML must be 100% identical• Start up the same Form every time (landing)• Pass the ‘real’ Form name to the landing form• Use WHEN-APPLET-ACTIVATED event to call that Form• Details are in Wilfred’s doc!!

if upper(event) = 'WHEN-APPLET-ACTIVATED‘then while true loop -- get the form name set_custom_property('BLK_PJC.PJC', 1,'EvalExpression','$v("CALL_FORM_NAME")'); formName := get_custom_property('BLK_PJC.PJC', 1, 'EvalResult'); call_form(formName); appletActive := get_custom_property('BLK_PJC.PJC', 1, 'AppletActive'); if appletActive = 'FALSE‘ then exit; end if; end loop;end if;

Page 20: Integration of APEX and Oracle Forms

Some additional remarks• Forms 10.1.2.0 • other versions tested by Oracle Support (incl

F11)

• SUN JRE version (1.6.05) • < 10 or • switch off “Enable next-generation Java Plug-

In

• Focus and Sticky Cursor Issues • Metalink Note 730581.1

Page 21: Integration of APEX and Oracle Forms

Some additional remarks• Forms 11g• web.javascript_eval• WHEN-CUSTOM-JAVASCRIPT-EVENT• legacy lifecycle• rebuild the jar file with new class files

Page 22: Integration of APEX and Oracle Forms

Some additional remarks• Authentication• ‘fixed’ user in formsweb.cfg• pass APEX credentials (DB Auth.) to the Form• use SSO• login into Forms (once)

http://localhost:7778/forms/frmservlet?config=apex&userid=&APP_USER./&P101_PASSWORD.@XE

Page 23: Integration of APEX and Oracle Forms

Conclusions

The challenge of converting Simple Forms (60%) Moderate Forms (30%) (Very) Complex Forms (10%)

Top 10 %

projectstart

projectfinish

Page 24: Integration of APEX and Oracle Forms

Conclusions

Convert the major part at once Convert the rest when

necessary/possible So reducing

effort – (re)build and test money risk

But you still need the Forms Server ($)

Top 10 %

projectstart

projectfinish

Page 25: Integration of APEX and Oracle Forms

Coming soon….

Whitepaper on OTN In cooperation with Iloon Ellen (@

Oracle)

Page 26: Integration of APEX and Oracle Forms

Question Time

My blog : http://roelhartman.blogspot.comMy e-mail : [email protected]