cancel
Showing results for 
Search instead for 
Did you mean: 

Application wide data

Former Member
0 Kudos

Hi,

I was wondering if there is a way to store data application wide like using application variables in ASP and JSP.

This way i can access them between session of different users. eg. If I want to maintain and display the number of users logged into the application at a particular time, I caould store it in some application variable at the server and use that between sessions of users who log in.

Accepted Solutions (0)

Answers (8)

Answers (8)

Former Member
0 Kudos

Dear Nirav

When an application is developed and deployed using NetWeaver Developer studio, we can easily maintain these using available APIs. The steps for adding these configurable properties and maintaining it using the J2EE visual administrator are given below:-

Create Development Component of type WebDynpro. Create an Application, Component and a view in this. Create a properties (simple text file which can be created using any text editor) file with the name 'default.properties' and put it in the src --> Configuration folder of the project. In this case the properties are maintained at the Deployable object level. The option is there to maintain these at the Deployable object part level, which are Application, Component or Component Interface. In this document the sample is shown to include it at the deployable object level.

In the wdDoInit method write the following line of code: WDConfiguration.getConfiguration("deployable object name ('vendor name/project name' in case of a DC)").getStringEntry("Key as maintained in the properties file.");

This would get the value for the specified key as maintained in the properties file.

To maintain these values using the visual admin the following steps are needed:-

Login to the Visual Administrator and select 'Configuration Adapter' under System ID --> Server Instance --> Services in the left side pane. Then in the right side pane expand webdynpro --> vendor name(com.wipro) --> project name(utilities).

After having switched to 'Change' mode, double click on the 'Propertysheet default' entry. The following screen is obtained. This has all the Key value pairs maintained in the properties file.

On double clicking on a particular property, the following screen is obtained where custom value can be maintained.

Note: If a custom value is maintained, a restart is required for this to take effect. Also if a re-deployment of the application is done, the values are overwritten by the properties file in the ear file

Please give me some points (10 atleast) if this is succesful

Regards

Jay Kapadia

Former Member
0 Kudos

Jay's approach won't work because you are not able to change configuration properties during web dynpro runtime. The values available through the configuration require a clusterwide restart, which is not what you want.

In order to share content across sessions, you will have to go outside of Web Dynpro and write your own persistence layer of some sort.

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Nirav,

let me give you an official statement concerning your issue from the Web Dynpro Java Runtime side:

<b>Status quo</b>

The Web Dynpro programming model <u>does not</u> provide an in-built concept for globally storing data across application borders.

The Web Dynpro runtime creates the following aggregation:

<i><b>User</b> - 1:1 - ServerSession - 1:* - ClientSession - 1:* - ClientWindow - 1:1 - <b>WD Application</b></i>

This means that you never can share data for different users or for different WD application instances of the same user but running in different browser windows.

Valery Silaev's proposed solution looks like this:

<i><b>User</b> - 1:1 - ServerSession - 1:* - ClientSession - 1:* - ClientWindow - 1:1 - <b>WD Container Application </b> (with root component) - 1:* <b>WD Logical Application</b> (with logical application components)</i>

Based on this approach the same user can switch between different logical applications in the same window instance. This application-switch is just based on firing outbound plugs to other logical component interface views combined with destroying and creating the used logical component instances. Valery's <i>'session scope variables'</i> are those context attributes belonging to the above root component which keeps alive all the time. To be exact, the container (or root) component does not have <i>'session scope'</i> but only <i>'client window scope'</i>. In this scenario the 'application wide data' is stored in a context of the container application.

Unfortunately this approach does not fulfil your given requirement (counter for the actually running applications in total, or the number of users).

<b>Proposed solution</b>

For really sharing global data across server session scope (for different users) you have to store this data in a database (e.g. the MySQL MaxDB) table and then access it via SQLJ. This database-approach also works in a cluster environment.

Regards, Bertram

Former Member
0 Kudos

No <i>generic legal</i> way exists so far. Under "legal" I assume public WebDynpro API.

What can be done is:

1. There is com.sap.tc.webdynpro.progmodel.model.api package, that contains classes for manipulating CMI models with certain scope (WDModelScopeType.APPLICATION_SCOPE closely resembles session). However, I'm not sure whether it works for custom CMI models or anything besides RFC models. You could explore this.

2. Create some kind of top-level container component, store all session data here. All of the rest components are hosted inside this container. These components may declare input nodes on component interface and session-scope variables will be "injected" via regular WD binding to context of surrounding container.

VS

Former Member
0 Kudos

Hi Nirav

You can Use portal service to share Application wide data. I tried it out in a pure WebDynpro App and it works fine.

regards

Ravi

Former Member
0 Kudos

Hi,

Inoder to retain data between sessions u better try stateless session beans. Declare static class variables in

the bean so that they are initailised once and can be modified by other business or nonBusiness methods in the bean.If u want to have client specific data to be stored then go for stateful session beans.

Former Member
0 Kudos

Kavitha,

The only problem remains is how to share statefull session handler between WD components -- this handle becomes session-scoped data on its own

VS

Vlado
Advisor
Advisor
0 Kudos

Wow! This is totally incorrect! EJB's <b><u>must not</u></b> use non-final static fields. For explanation see http://java.sun.com/blueprints/qanda/ejb_tier/restrictions.html#static_fields

Best regards,

Vladimir

Former Member
0 Kudos

Is using protal services for a standalone web dynpro application a good practice?

Please give me a sample code or tutorial to try this.

Former Member
0 Kudos

Hi Nirav

The Portal Services will work only if you have a portal runtime.

Regards

Pran

Former Member
0 Kudos

Hi

Nirav , you can try your scenario using Portal Services. Portal Services help you to store data in a Global Area. There are some documents available on how to use Portal Services.This works fine when the WebDynpro Component is made an iView in the portal.

But if it is a pure WebDynpro App then i dont know if that will work. I will give it a try and let you know.

regards

Ravi

Former Member
0 Kudos

Hi,

I suppose this could help u to some extent. U can define a context which is global to all users and what ever the data u want to put in session bing the value with the variable defined in context.

But this could help u only with fixed no of variables(if u know in advance).Not sure whether u have a way to dynamically create a variable in context.If this happens then ur problem will be solved.

Former Member
0 Kudos

Exactly, but how do I create such a context variable?

Former Member
0 Kudos

Hi,

Create a CustomController(say by name Session) and assign the controller to each and every view in which u want use the session scope objects. Through the context of this controller u can play with the values in context in all the views which are using this one.

If u do this through the follwing way u can get the variables:

wdThis.wdGeTSessionController().wdGetContext().<set/get(variableName)>

Hope this could solve your session problem.

Former Member
0 Kudos

Will naming a context "Session" make it available to everyone who logs into the site? I dont think thats so. The context object will be created separately for everyone who hits the site.

I want something by which the same context is preserved and the data be available common to all users who hit the site. One way would be to store the data in a database or file or such a persistent source, but I dont want to do this.

There should be a way to such create application wide data, because ASP and JSP support such a thing by "application variables".

Former Member
0 Kudos

Hi Nirav

What Sreenivas meant was to have a custom controller which is attached to all the Views or other controllers, by which this custom controller can have context that can be shared. But this will work only for intra component data sharing. Except for the Interface controller no other controller can be shared cross-component.However the context of the Interface controller does not seem to be shareable(I think) and so wont serve the purpose of a global context. What you might need to do is to pass the values around. I am still trying to find a more elegant solution to this.

Regards

Pran

Former Member
0 Kudos

Hi if the no of client users is what you want try this

WDServerState.getNumberOfClientUsers()

Regards

Pran

Former Member
0 Kudos

No, the number of clients was an example. I actually want to know how to store variables that i can use across sessions for the application.