How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010....

34

Transcript of How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010....

Page 1: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent
Page 2: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

How to integrate APEXand Oracle FormsRoel Hartman

Page 3: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

No. 3© Logica 2010. All rights reserved

How to integrate APEX and Oracle Forms

OGh APEX Dag

Page 4: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

Introduction

Page 5: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

Who am I

Oracle since v5, Forms 2.3, Case*Designer etc

Presenter at UKOUG (2x), OOW (2x), ODTUG

APEX 3.2 EAR

OTN Forum

Articles

Blogger

OGh APEX Dag No. 5

Page 6: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• APEX 3.2 : Forms conversion

• The challenge of converting• Simple Forms (60%)

• Moderate Forms (30%)

• (Very) Complex Forms (10%)

Introduction

OGh APEX Dag

projectstart

projectfinish

No. 6

Page 7: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

OraFormsFaces

Thank you Wilfred!

The concept comes from…

http://www.oratransplant.nl/files/formsInJSF/Forms-as-Web-Components-Step-By-Step.pdf

OGh APEX Dag No. 7

Page 8: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

Embed a Form in APEX

Page 9: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• Insert HTML• PL/SQL Procedure• URL

http://localhost:7778/forms/frmservlet?config=apex&module=orders

Embed a Form in APEX

OGh APEX Dag No. 9

Page 10: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

Embed a Form in APEX

OGh APEX Dag No. 10

Page 11: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

APEX PAGEAPEX PAGE

APEX REGIONAPEX REGION

Embed a Form in APEX

ORACLE FORMORACLE FORM

OGh APEX Dag No. 11

Page 12: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

Visual Integration

Page 13: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• 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

Visual Integration

<div id="outerdiv" style="overflow:hidden; border-s tyle:none;"><div id="innerdiv" style="overflow:scroll; border-s tyle:none;">

#BODY#</div>

</div>

OGh APEX Dag No. 13

Page 14: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

Visual Integration

OGh APEX Dag No. 14

Page 15: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

Communicate from Forms to APEX

Page 16: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• 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.

Communicate from Forms to APEX

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

web.show_document('javascript:'||pScript, '_self'); END;

OGh APEX Dag No. 16

Page 17: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• Call procedure from WHEN-NEW-RECORD-INSTANCE

• Create procedure TriggerApex

Communicate from Forms to APEX

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 Pag e 9 -- & Show the data on the Map runJavascript('refreshReport('||

name_in('PRODUCTS.PRODUCT_ID')||', ''P9_PRODUCT_ID'');showOnMap();');

end if;end if;

END;

OGh APEX Dag No. 17

Page 18: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

Communicate from Forms to APEX

OGh APEX Dag No. 18

Page 19: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

Communicate from Forms to APEX

APEX PAGEAPEX PAGE

APEX REGIONAPEX REGION

ORACLE FORMORACLE FORM

APEX REGIONAPEX REGION

APEX FormAPEX Form

APEX ReportAPEX Report

APEX ChartAPEX Chart

web.show_document

OGh APEX Dag No. 19

Page 20: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

Communicate from APEX to Forms

Page 21: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

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.

OGh APEX Dag No. 21

Page 22: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• Read Forms-as-Web-Components-Step-by-Step.pdf

• raiseEvent procedure – extends the Forms runtime

• CommunicatorBean – receives external events

• Add PJC to your Form

Communicate from APEX to Forms

OGh APEX Dag No. 22

Page 23: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• 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

Communicate from APEX to Forms

PROCEDURE execEvent ISBeanEventDetails ParamList;ParamType number := text_parameter;Event varchar2(1000);Payload varchar2(1000);

beginBeanEventDetails :=

get_parameter_list(name_in('system.custom_item_even t_parameters'));get_parameter_attr(BeanEventDetails, 'Event', Param Type, Event);get_parameter_attr(BeanEventDetails, 'Payload', Par amType, Payload); if name_in('system.current_form') = 'CUSTOMERS'then if upper(event)='EXECUTE_QUERY'

thenset_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 RequeryexecFormAction( '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 p arametersrunJavascript('refreshReport('''', '''')');

end if;

OGh APEX Dag No. 23

Page 24: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

Communicate from APEX to Forms

APEX PAGEAPEX PAGE

APEX REGIONAPEX REGION

ORACLE FORMORACLE FORM

APEX REGIONAPEX REGION

APEX FormAPEX Form

APEX ReportAPEX Report

APEX ChartAPEX Chart

web.show_document

PJC

APEX REGIONAPEX REGION

Extended Forms Applet : raiseEvent

Extended Forms Applet : raiseEvent

CommunicatorBean / PJC

CommunicatorBean / PJC

WHEN-CUSTOM-ITEM-EVENT

WHEN-CUSTOM-ITEM-EVENT

LibraryLibrary

OGh APEX Dag No. 24

Page 25: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• Prevent multiple FRM 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

• Details are in Wilfred’s doc!!

Using the Applet Life Cycle

OGh APEX Dag

if upper(event) = 'WHEN-APPLET-ACTIVATED‘then

while true loop-- get the form nameset_custom_property('BLK_PJC.PJC', 1,'EvalExpressio n','$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;

No. 25

Page 26: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

A sidestep: APEX in Forms

Page 27: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• Change the baseHTML template

• Add an IFRAME in a DIV• Add a ShowApexReport function• Call that function from a button

APEX in Forms

OGh APEX Dag

<DIV id="APEXDIV"; style="visibility:hidden"><IFRAME src=""

style="width:800px;height:450px;visibility:hidden" name="APEX" id="APEX" scrolling="auto" marginwidth="1" marginheight="1"frameborder="1" vspace="1" hspace="1"

/></DIV>

function ShowApexReport( pApp, pPage, pID ){if (document.getElementById("APEX").style.visibilit y=="visible"){ document.getElementById("APEX").src =

"http://localhost:7778/pls/apex/f?p="+pApp+":"+pPag e+"::::RP,"+pPage+",RIR:IR_CUSTOMER_ID:"+pID;

}

PROCEDURE ShowApexReport( p_app_no number, p_page_no number, p_id number ) IS

BEGINweb.show_document('javascript:ShowApexReport(

'||p_app_no||','||p_page_no||','||p_id||');', '_sel f'); END;

No. 27

Page 28: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• Forms 10.2.0.1

• 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

OGh APEX Dag No. 28

Page 29: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

Some additional remarks

• Forms 11g

• web.javascript_eval•WHEN-CUSTOM-JAVASCRIPT-EVENT

• legacy lifecycle• rebuild the jar file with new class files

OGh APEX Dag No. 29

Page 30: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• Authentication• Fixed user in formsweb.cfg

• pass APEX credentials (DB Auth.) to the Form

• use SSO

• login into Forms (once)

Some additional remarks

OGh APEX Dag

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

No. 30

Page 31: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• The challenge of converting• Simple Forms (60%)

• Moderate Forms (30%)

• (Very) Complex Forms (10%)

Conclusions

OGh APEX Dag No. 31

Page 32: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

© Logica 2010. All rights reserved

• 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 ($)

Conclusions

OGh APEX Dag No. 32

Page 33: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent

Logica is a business and technology service company, employing 39,000 people. It provides business consulting, systems integration and outsourcing to clients around the world, including many of Europe's largest businesses. Logica creates value for clients by successfully integrating people, business and technology. It is committed to long term collaboration, applying insight to create innovative answers to clients’ business needs. Logica is listed on both the London Stock Exchange and Euronext (Amsterdam) (LSE: LOG; Euronext: LOG). More information is available at www.logica.com

Thank you

Roel Hartman

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

Page 34: How to integrate APEX - nlOUG · How to integrate APEX and Oracle Forms Roel Hartman ©Logica 2010. All rights reserved No. 3 ... PJC APEX REGION Extended Forms Applet : raiseEvent