How to integrate APEX and Oracle Forms? Roel Hartman
Nov 22, 2014
How to integrate APEX and Oracle Forms?
Roel Hartman
Who am I?
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
Introduction
APEX 3.2 : Forms conversion
The challenge of converting Simple Forms (60%) Moderate Forms (30%) (Very) Complex Forms (10%)
Top 10 %
projectstart
projectfinish
The concept comes from…
OraFormsFaces
Thank you Wilfred!
Embed a Form in APEX• Insert HTML• PL/SQL Procedure • URLhttp://localhost:7778/forms/frmservlet?config=apex&module=orders
Embed a Form in APEX
APEX PAGEAPEX REGION
Embed a Form in APEX
ORACLE FORM
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>
Visual Integration
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;
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;
Communicate from Forms to APEX
Communicate from Forms to APEX
APEX PAGEAPEX REGION
ORACLE FORM
APEX REGIONAPEX Form
APEX Report
APEX Chart
web.show_document
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.
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
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;
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
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;
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
Some additional remarks• Forms 11g• web.javascript_eval• WHEN-CUSTOM-JAVASCRIPT-EVENT• legacy lifecycle• rebuild the jar file with new class files
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
Conclusions
The challenge of converting Simple Forms (60%) Moderate Forms (30%) (Very) Complex Forms (10%)
Top 10 %
projectstart
projectfinish
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
Coming soon….
Whitepaper on OTN In cooperation with Iloon Ellen (@
Oracle)
Question Time
My blog : http://roelhartman.blogspot.comMy e-mail : [email protected]