on 06-13-2007 10:44 AM
Dear Developers,
I am developping a multicomponent application. I have a model component which is the model of my MVC and is created from my main component.
I have other components which are loaded dynamically at runtime and which also define a usage to this model component.
The use of my model component is only relevant to the application if this component is a singleton in my work process.
Is there a builtin way to get a list of instances of a component usage within my work process?
How can I share "component instances" (of a usage which points to the same class or interface) between components ? Which would be the best way or the WD4A way ?
Sincerely,
Olivier MATT
Hi again.
Another way would be to inject the model class to all other components via a set method in the component interface.
So the main component would initially create the model and pass it to all other components via their interface controllers.
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,
My original idea was to use a normal ABAP class with the singleton DP.
But I have seen people writing model components and using special magic with the USAGE_MODEL definition which seems to have its own way to be dealt with.
I had a look into IF_WD_COMPONENT_USAGE~CREATE_COMPONENT method then I see MODEL_USAGE TYPE REF TO IF_WD_COMPONENT_USAGE OPTIONAL.
What is the use of this ? What is the WD4A way to deal with models ?
Could the architect or developers of the framework enlighthen us ? .. or you Sascha if you know it
Best regards,
Olivier Matt
Hi Olivier.
This is another way to transfer the reference of the usage to a used component.
If you define a component usage of the type of your model_component in the target component (which should use the same reference) and you name this usage MODEL_USAGE you can transfer your model component usage via the create_component method.
Example:
data:
lr_model_comp_usage type ref to if_wd_component_usage,
lr_modeluser_comp type ref to if_wd_comp_usage.
lr_model_comp_usage = wd_this->wd_cpuse_usage_modelcomp( ).
if lr_model_comp_usage->has_active_component( ) is initial.
lr_model_comp_usage->create_component( ).
endif.
lr_modeluser_comp = wd_this->wd_cpuse_usage_modelusercomp( ).
if lr_modeluser_comp->has_active_component( ) is initial.
lr_modeluser_comp->create_component( model_usage = lr_model_comp_usage ).
endif.
Cheers,
Sascha
Hi again,
just have a look on Regina's and Thomas's statement in this thread:
https://forums.sdn.sap.com/click.jspa?searchID=3159927&messageID=2666391
Cheers,
Sascha
Message was edited by:
Sascha Dingeldey
Hi Olivier.
It is possible to pass the reference of the usage from your main component which controlls everything to all
other components that have a usage to the same component.
So all your components should have a set_usage method which takes the
reference to the usage. Your main component then can call this method and pass
the reference.
In the implementation of this method in all other components do the following:
data:
lr_usage type if_wd_component_usage.
lr_usage = wd_this->cpuse_usage_name_of_usage( ).
lr_usage->enter_referencing_mode( lr_usage_refrence_from_main_component ).
But I would recommend not to use compoents as model. Just create a normal
class or set of classes which reflects your model and build it as singleton. Then
you can access it from each component. Guess this is easier.
Cheers,
Sascha
Message was edited by:
Sascha Dingeldey
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.