cancel
Showing results for 
Search instead for 
Did you mean: 

Why Context Mapping is always null for my embeded view?

Former Member
0 Kudos

I have created 3 views in 3 different components. View A has 2 view containers, one embedding View B and the other embedding View C.

I was trying to have View B pass View A and View C some data by having View B's interface fire an event. View A received the event but for some reason View C refused to receive it.

I also tried to use context mapping. However, once again View C was giving problems. The mapped context data is always null! but View A was getting the correct data

Is it becos View A is embeding View B thus it can always get the data? doesnt seem quite right....

Is there something i did wrong? Pls help!

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

ah,

Pardons -- I misunderstand your post. You are talking about interface views of separate components, I assumed you are talking about "plain" views in single component.

The reason for behavior may lay in fact that Component C (with ViewC interface view) is not created up to moment you are firing event. On other hand, seems that Component B was created, hence the difference.

Make sure that Component C usage has option createOnDemand -- this should fix context mapping but not eventing. Better, create Component C usage explicitly in code of Component A before firing event.

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

ah,

First, does view really fires events? AFAIK events may be declared only on component/custom/interface controllers but not on view. So do you in fact firing plugs (rather then events) or you are firing events via component controller?

Second, is view C a default view in it's view container? Or there are another one (even empty) that is visible by default?

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hi Ah,

were or better when do you fire your view events. I assume that the event is fired in view B before view A is created by the Web Dynpro Java Runtime. Do not fire these events in wdDoInit() hook methods.

Why do you really need this serverside eventing?

Regarding your context mapping issue: make sure that your mapping chain is not broken.

Regards, Bertram

Former Member
0 Kudos

I'm sorry, let me describe my situation in more detail.

View A is my main form why View B and View C are views that are reused in many other views. View A has 2 view containers in it. One for B and one for C.


-- view A --

////////////////

/// view B //

////////////////

////////////////

// view C ///

////////////////


However, View A and View C both requires data from View B for defaulting purposes. When the user clicks on a button in View B (at this point both A and C are already visible and available for user interaction), it will retrieve data from a bapi. After which some of these data retrived in B is needed in A and C.

I first tried to get View B to fire an event via its interface to pass the data that view A and View C needs. After that failed, i tried to do it via context mapping which should be simple enough, but some how the data is always null in View C.

Both View A and View C are already visible on the screen an the point when the event was triggered.

Bertram: What do u mean by mapping chain is broken?

Valery: C is set createOnDemand. Besides C is already visible and available for user interaction at the point of the event being fired.

TIA

Former Member
0 Kudos

ah,

I repeat my advise: try to create usage of component C explicitly (pseudocode below):


if ( !wdThis.wdGetComponentCUsage().hasComponent() )
  wdThise.wdGetComponentCUsage().createComponent();

Valery Silaev

SaM Solutions

http://www.sam-solutions.net

Former Member
0 Kudos

Hi Valery,

I have tried as u suggested. Unfortunately the same problem still occurs.

Former Member
0 Kudos

I just tried, when i map the values from View C to View A instead of C to B it works... strange

Can i check with u guys, if context C is mapped to context B, but C was created after B retrieved data. Will C automatically have its context populated with B's data when it is created?

Former Member
0 Kudos

Ok i think i have found the reason for the strange behavoir.

I think View C is referencing a different object instance of View B. After several test, i realize View A and View C can alter the values in View B without affecting one another.

This is probably becos View A embeds B + C , and view C uses View B. Some how this causes View C to have its own instance of View B which is different from View A.

Is there any solution for this? My only work around is to have View C get the data it needs from A instead of B

BeGanz
Product and Topic Expert
Product and Topic Expert
0 Kudos

Hallo Ah,

when you have declared a component usage model like this:

Comp A

|_ Component Usage to Comp B

|_ Component Usage to Comp C

Comp C

|_ Component Usage to Comp B

the Web Dynpro Runtime will create two separate component instances of type component B in components A and C. Is this really your component usage model? When yes, the broken event chain from B to C is clear for me. Comp B is not a singleton here.

<b>Solution A (not preferred): Referencing Mode </b>

To reference the same (existing, singleton) component instance of component B in component C you must enter the related component usage in referencing mode. But this referencing mode is only supported for faceless components or for visual components that are not displayed on the UI. This means you cannot display component interface view B within component C, when the lifecycle of component usage B is managed by component A (ughh, very complicated, I admit). The referencing mode only works on a controller not on an interface view level.

<b>>>>> Solution B (preferred): External Context Mapping</b>

First skip the component usage B within component C. To pass data from component B to components A and C you just declare an isInputElement=true context within both component interface contexts of component B and C. The data context is declared in component A and the context mapping from the interface contexts of the used component interfaces B and C to the data context is externally mapped within the parent component A.

<b>What we learned from this</b>

<i>Defining multiple usages of the same component does not imply that these usages point to the same component instance at runtime.

And, the most simple approach to transfer data from outside a component to inside a component is to apply external context mapping but not serverside eventing.</i>

Regards, Bertram

Former Member
0 Kudos

Hi Bretram

Thx for the reply. I already discovered the reason why the context mapping is null.

I don't really understand ur Solution A. I understand solution B but i was actually not really familiar with what the "isInputElement" field does. Besides i already did my own work around.

Any comments on how my solution works? any major drawbacks?