cancel
Showing results for 
Search instead for 
Did you mean: 

Method which is called by browser-close resp. session close

0 Kudos

Hi,

When a user closes the browser or a session expires I need to call an unlock-method for some objects. This method should prevent that the lock for this object is always there.

Can you tell me how or is there another approach for this problem?

thanks

Mathias

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Mathias,

the browser sends an event on close (and unload) for which an event handler is registered in the WD runtime. This handler exits the corresponding component controller, which leads to a call of the wdDoExit() methods of the component and all dependant controllers. So it should be sufficient to put the "unlock" functionality you need into the wdDoExit methods of the controller(s) which locked the objects.

Hope that helps.

Regards

Stefan

Former Member
0 Kudos

Hi Stefan

I did a trace on the wdDoExit method and indeed it is called when the object is unloaded . But try doing a multiple refresh on the page and it is interesting to see that in some cases the wdDoInit of the next object is called before the wdDoExit method of the previous object is called and in some cases wdDoExit is never called and you would have to wait for Web Dynpro time out for these objects to actually be unloaded and release any connections they are holding.

Mathias : We too implemented locking via RFC but we saw that the user locks himself out if he does multiple refreshes(fast) on the same page , specifically because the wdDoExit is not being called and the lock not being released

Regards

Pran

0 Kudos

Hi,

thanks for participating. Well I think the situation you mentioned doesn't happen often, or?

And After a period of time (WD timeout) the wdDoExit is called, or?

So wdDoExit should work.

Regards

Mathias

Former Member
0 Kudos

Hi Pran,

ok, but what are the alternatives? I don't see any other possibility to "catch" the end of a session and do the cleanup/unlock. Any ideas?

Best regards

Stefan

Former Member
0 Kudos

Yep,

import com.sap.tc.webdynpro.services.session.IMaintainScope;
import com.sap.tc.webdynpro.services.session.IScopeListener;
import com.sap.tc.webdynpro.services.session.Utils;
import com.sap.tc.webdynpro.services.session.api.WDScopeType;

...

private void sessionSample()
{
  final IMaintainScope sessionManager = Utils.getScopeMaintainer( WDScopeType.CLIENTSESSION_SCOPE );
  sessionManager.registerToBeDestroyedListener
  (
    new IScopeListener()
    {
      public void scopeToBeDestroyed(IMaintainScope maintainScope)
      {  		
        /* Your cleanup logic here */
        maintainScope.unregisterToBeDestroyedListener( this );	
      }
    }
  );
}

WBR,

VS

Former Member
0 Kudos

Nope,

this is <b>not</b> a solution, i only see usage of non-public API except WDScopeType. Didn't your mother tell you not to use these?

Best regards

Stefan

Former Member
0 Kudos

Hi,

Thanks God my mom doesn't stay behind me when I'm typing this...

Conventional wisdom says that if somethig forbidden is very desirable, then it is allowed

Seriously, there is no way to do a LOT of things in WD without resorting to such API calls. I agree that these calls should be avoided at all cost, but...

1. How to use Servlet-like session without IScope?

2. How to intercept request/response cycle without IPhaseListener?

3. How to use ThreadLocal safely in WD (where java threads are allocated from pool and swaped between users) without ITask?

4. How to embedd arbitary component interface view dynamically without calls to addRelatedModelObject / setRelatedModelObject with hard-coded internal relation names?

5. How to replicate runtime repository content to external storage and further restore it on different server without refering classes in *.repository package?

6. How to... you may continue the list

Well, I need such functionality now and cannot wait till SP_XXX to be released in several monthes from now.

Regards,

VS

Former Member
0 Kudos

All nice and well. But you should not promote here in SDN a programming practice that is neither supported nor guaranteed to work over time.

Rule: Never use non-public Web Dynpro APIs or classes. Exceptions: none.

If you have proposals or requests, feel free to post them here.

Armin

Former Member
0 Kudos

Armin,

I firmly believe you understand, that it is more like complaining rather then promoting of BAD THINGS

VS

Former Member
0 Kudos

Psst Valery ... (read in whisper tone)

Dont let the guys above know but how did you figure out how to use them :B

Former Member
0 Kudos

Hello Valery,

could you please elaborate on the problems you found, perhaps for each problem in a separate thread?

Thank you.

Armin

0 Kudos

Hi Armin,

thanks for participating...

Do you have a solution for my problem?

Best Regards

Mathias

Message was edited by: Mathias Essenpreis

Sorry. I got an Exception after posting my question. Thus I thougt that my question wasn't posted.

0 Kudos

Hi Armin,

thanks for participating...

Do you have a solution for my problem?

Best Regards

Mathias

Former Member
0 Kudos

(Java Browsing Perspecive) + (JADClipse plugin) + Beer - (Free time)

VS

Answers (1)

Answers (1)

0 Kudos

Hi Armin,

thanks for participating...

Do you have a solution for my problem?

Best Regards

Mathias