Skip to Content
avatar image
Former Member

Web dynpro Views and Javascript function call

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?

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

2 Answers

  • Apr 24, 2015 at 08:55 AM

    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

    Add comment
    10|10000 characters needed characters exceeded

    • 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

  • Nov 30, 2015 at 07:36 AM

    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.

    Add comment
    10|10000 characters needed characters exceeded