cancel
Showing results for 
Search instead for 
Did you mean: 

Maintaining caching for a user session in webdynpro

RajeevKansal
Advisor
Advisor
0 Kudos

Hello,

Is it possible to cache the data in webdynpro for one user session something like what stateful EJB does?

Thanks.

Best Rgds

Rajeev

Accepted Solutions (0)

Answers (4)

Answers (4)

Former Member
0 Kudos

Hi!

It seems to work but sometime I get a ClassCastException when I cast the object from the get method. This only happens when I run my wdp from Netweaver studio.

My code is like:

IMaintainScope maintainer = Utils.getScopeMaintainer( WDScopeType.CLIENTSESSION_SCOPE );

Scope scope = maintainer.getScope();

MyClass x1=(MyClass)scope.get("myKey");

I solved it by catching the exception (java.lang.ClassCastException). This problem is minor as I think it only happens when the wdp is run from Netweaver studio...

RajeevKansal
Advisor
Advisor
0 Kudos

Thank you both for your reply.

I was talking about the user session which can keep the info even if the webdynpro application is destroyed but the user is still in portal on some other page. if he comes back to same webdynpro application again then I can retrieve the data i had saved prevously from database into client session.

I think Maksim code would help me out in that.

Please let me know if I am wrong.

Thank you

Rgds

Rajeev

Former Member
0 Kudos

Did that solve your problem ?

I'm facing the same kind of requirements for my wdp application...

Thanks

former_member182372
Active Contributor
0 Kudos

...

FPI usage deleted.

Message was edited by: Maksim Rashchynski

Former Member
0 Kudos

Maksim,

I tried your approach using CLIENTSESSION_SCOPE and was

able to leverage objects across applications.

I noticed that if I logged off using the Portal Logoff

and logged back in with the same Browser my Webdynpro session objects were still available.

Is there a way to clear the objects when invoking the Portals Logoff?

Thanks,

Former Member
0 Kudos

Hi,

Session works fine in Web Dynpro applications only if the servlet.jar is added to the build path of the project. The objects would remain alive till the session ends (user logs off) and could be made available across applications. Hope this helps.

Srinivasan T

Former Member
0 Kudos

Hi Srinivasan,

I had added the appropriate servlet.jar to the build path when I built my application. I am able to use the variables from the session across applications. My issue is that when I use the Portal Logoff and come back to my application, the value of my session attributes are still valid in the session.

If I close the browser it's fine, otherwise the data still exists.

Thoughts?

Thanks,

John

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo,

there is no inbuilt, generic mechanism provided by the Web Dynpro Java Runtime which can be used to share data across several Web Dynpro client sessions.

I repeatedly refer to my WebLog on <a href="/people/bertram.ganz/blog/2005/02/02/never-ever-hijack-internal-web-dynpro-classes-and-interfaces">Never Ever Hijack Internal Web Dynpro Classes and Interfaces</a>. With the first new SAP NetWeaver Release your "hack-solution" won't work any more at all, because all internal FPIs like IMaintainScope, IScope will be hidden behind a Web Dynpro API Fassade, so that you cannot import the related packages within your controller classes at designtime any more.

Like Valery allready mentioned the proposed solution is to persist this session wide data in a database. To access this data you can either use a Web Service Model or you import a Java Bean Model which is a Command Bean Layer calling EJBs.

Regards, Bertram

Former Member
0 Kudos

Hi John,

Normally once you have logged off from the portal, the user session ends and when you logon again, the session objects selected earlier would not be available. I have tested this in my applications.

Srinivasan T

Former Member
0 Kudos

Hi Bertram/VS,

is there any example available to use EJB Model or web service model for the session management?

Thanks!

Former Member
0 Kudos

Rajeev,

1. Nothing prevents you from using SFSB itself with WD.

2. There is no access (via API) to HTTP session in WD.

3. Lifecycle of WD Controllers (Custom Controller, Interface Controller, Component Controller and View Controller with <i>framework_controlled</i> lifespan policy) closely adheres to your needs -- all of them are created on demand and stay alive for component life-time. So unless you manually creates / destroy components via ComponentUsage from embedder component, you may use controller context or private variables as UI-level cache.

Regards,

VS