cancel
Showing results for 
Search instead for 
Did you mean: 

How to Start(!) a Component from another Component

detlev_beutner
Active Contributor
0 Kudos

Hi there,

my question of today is the following:

I have a component A (working standalone) and a component B, which makes use of component A. To be visual: A is a three-step wizard, B is a table to choose from.

Now I want to start component A (the wizard) whenever the user chooses a new row in B. What I have is component B calling the interface view of component a, bypassing a parameter. This works. But when the user moves forward within the wizard, from step 1 to step 2 within component A, and then chooses another row in component B, the parameter is passed, I can update the context, but the view does not change - but I want to start over this component. The inbound plug of the interface view is marked as a startup plug, I do not really know if this should concern my question (doc is a bit short again on this).

Any help?

Thanks in advance

Detlev

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi Detlev,

here's my solution of the day:

1. Change the Lifecycle property of the component usage of A owned by B to "manual".

2. Whenever the user selects a row, delete and recreate A (-> full "restart"):


    if (wdThis.wdGetAComponentUsage().hasActiveComponent()) {
      wdThis.wdGetAComponentUsage().deleteComponent();
    }
    wdThis.wdGetAComponentUsage().createComponent();

3. Fire the plug to A passing the parameter(s) as already done. If the InterfaceView of A is the default for the view area it resides in, it will be displayed by the component creation of A already, so firing the plug is just for transporting the parameters(s) in that case.

4. In wdDoExit() of the component controller of B, delete the component A for a full cleanup (maybe that's automatically done by the framework, but who knows):


    if (wdThis.wdGetAComponentUsage().hasActiveComponent()) {
      wdThis.wdGetAComponentUsage().deleteComponent();
    }

5. What you are doing here is a navigation inside an already running application, so there's no need to use startup plugs for that.

Hope that helps.

Best regards

Stefan

detlev_beutner
Active Contributor
0 Kudos

Hi Stefan,

yeah, great, yuppieh, thanks ))

This will make three points for you (today I'm very generous

Best regards

Detlev

PS: I have controlled the user action within the view's implementation, so I had to implement parts of your solution within the actionHandler, parts within the component controller (because there is no access from the view's implementation to wdThis.wdGetAComponentUsage()... of the component controller). Is this the way I should go or is this a rumble way and I have overseen again the big smooth path?

Former Member
0 Kudos

Hi Detlev,

wow, then i'm allowed to reply two times nonsense now

P(re)S(criptum):

1. The manual control of component usage lifecycle should stay the exception from the rule.

2. You are wrong (i'm nearly sorry to say that), that you can't reach the usage from the view controller. Component usages are public throughout the whole component declaring the usage. For the view- and any other controller, you can add the usage as a required controller in the Properties tab.

3. From my point of view, a good design decision is to follow a top-down approach in how controllers use each other (but it's not always possible to do that).

I'm getting an uncomfortable feeling, if a View controller uses the Component Interface controller in tight coupling, calling methods there. Events are something different, Context bindings reverse that order according to mapping, in this case the data sink should be as central (topmost) as possible.

4. I would place the component creation and deletion into the component controller normally, since it has something to do with the whole component and that's what the component controller is designated to handle.

5. In the current use-case this is not sufficient, since you want to (re)create A in an action. So in this special case i would create the component in wdDoInit, delete it in wdDoExit and recreate it in the action handler, all inside the view controller.

Best regards

Stefan

detlev_beutner
Active Contributor
0 Kudos

Hi Stefan,

1.) That's what I thought when I created the component usage.

2.) Hm. When a tried around, I thought that this should be possible, I even thought to have tried to mark this, but it seems that I was not really up in mind. Tried again now, and it worked (if I was Gollum, I would beat me now. Thanks god, I'm not

3.) & 4.) & 5.) I completely agree.

Now I am really happy with my solution.

Thanks, thanks, thanks & have a nice weekend!

Best regards

Detlev