on 05-15-2007 10:17 AM
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
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
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
User | Count |
---|---|
84 | |
24 | |
11 | |
9 | |
7 | |
6 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.