cancel
Showing results for 
Search instead for 
Did you mean: 

Sharing data between components....

Former Member
0 Kudos

Dear developers,<br><br>

I would like to share an ABAP object between several components.

This object is somehow the M of my MVC.

<br><br>

I am not sure if its a good idea to do this, but if I define an assistance class with a class attribute which is my object (and then only created once) and I define this assistance class for each component, then I would get this object shared between my components through the assistance class.

<br><br>

Does it sound to be a good solution?

How would you do this ?

<br><br>

Second question: assuming this object has been created, I bet it would be only shared for the webdynpros running in the same workprocess. If I login with the same user again on the same WD4A application, a new workprocess will be loaded to run the application right? So the objet will not be shared between different logons in the WD4A. Is this correct?

<br><br>

Thank you for your precious help,

<br><br>

Olivier MATT

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Olivier.

When you create a component the instance of the assistance class is created

new. So when you set youtr object thru component A and component B is created

there won't be any object in component B's assistance class.

You can share objects thru external mapping or directly thru defining methods in

components as interface methods which take a reference of your model object.

Another way would be using the singleton pattern for your model class.

Second question: Right.

Hope this helps,

Cheers,

Sascha

Former Member
0 Kudos

Hi Sascha,

This is what I do. I use a singleton pattern and the sigleton is a static attribute (or class attribute).

Former Member
0 Kudos

Ok,

and your question is, whether this is the best way?

or do you need to share this object between multiple user?

Cheers,

Sascha

Former Member
0 Kudos

Hi Sascha,

<br><br>

No I dont need to share the data between several users. So it should be fine.

<br><br>

But what is the best way to provide a model to components?

<br>

<ul>

<li>assistance classes providing methods</li>

<li>interface methods of the component</li>

<li>sharing data with the context</li>

</ul>

What are your personal preferences? What are the pros and the cons?<br><br>

Sincerely,<br><br>

Olivier MATT

Former Member
0 Kudos

Hi Olivier.

In most cases using the assistance class fits. Here are methods to perform selections or to access model classes.

If the model is a simple BAPI I prefer using a service call in component controller.

Sometimes it is necessary to inject the model via interface methods or external mapping. A good example is the ALV component in WDA.

It is hard to say what is the best way cause it always depends on how a component should work and be usable by other components.

Cheers,

Sascha