cancel
Showing results for 
Search instead for 
Did you mean: 

Web dynpro Views and Javascript function call

former_member1540
Discoverer
0 Kudos

Hi,

I have currently added 1 MIME object for .js file which includes some functions to open and close web socket connection, no UI part is involved.

HTMLIsland is used for adding JS to webdynpro ABAP application.

The scenario is like, there are 2 views V1 and V2.

The navigation is created from V1 to V2 and vice-versa using plugs.

when V1 is loaded one of the JS function is called to create the connection and when through plug V2 is loaded, I want to trigger the another JS function to close the connection

But somehow, the close function on V2 is not triggered immediately when V2 is loaded, it triggers when control to V1 is coming back.

Any suggestion on how to handle this scenario?

Accepted Solutions (0)

Answers (2)

Answers (2)

ulyssesbonfim
Explorer
0 Kudos

Got exactly same problem and thanks for describing it so well. Helped us a lot!

Java script calls are only evaluated after the next HTMLContainerElement's WDDOMODIFYVIEW (your V1's WDDOMODIFYVIEW) are executed, which turns out to be a problem if you also want to navigate from V1 to V2.

In this scenario V2 will be executed and V1 will be put on hold, not running your JS calls until you navigate back to V1.

You can test it debugging your and JS files and also with WDR_AMC_TEST component.

The solution, or workaround, is to also include HTMLContainerElement into V2, triggering a screen refresh even after you navigate from V1.

So, create a view DUMMY_JS_VIEW, put your JS files on it and embed it into V1 and V2.

TL;DR: Javascript's container must be visible on V1 and V2.

ramakrishnappa
Active Contributor
0 Kudos

Hi,

Is the second JS function is available in view V2 ?

I think you better set the lifetime of view to When visible in the properties tab of view.

Also, try the below steps.

  •   Right click on mime object or your image
  • Choose option "Expiration Time client cache"  from menu
  • Check the individual expiry date check box and un-check the Expiry active as below

    

Note: you can do it for individual image or for all mimes in a component

Hope this helps you.

Regards,

Rama

former_member1540
Discoverer
0 Kudos

Hi Ramakrishnappa,

I have already set this option for .js file.

Can you please tell me how the web dynpro hook methods can impact this JS function call?

Because if V2 is already loaded and on some button click if I call the other JS function to close the socket without navigating back to V1, then it works fine. but it doesn't when navigation to V1 is added.

ramakrishnappa
Active Contributor
0 Kudos

Hi,

Are you calling js function after navigation call? if so, your js call to close connection should go first and then wait for a moment and finally navigate to v2.

Example:

.... close connect ... close( )

----- wait up to 1 sec.

---- navigate .... wd_this->fire_to_v1_plg( ).

Hope this helps you.

Regards,

Rama