Reputation:
I have two views in my Java Web Dynpro application and I want to share one variable between them so that when a string is submitted in the StartView I can show it in the ResultView. I'm a little confused about how the mapping works though.
I created a value attribute
called Username
inside my component context like this and this. Then I created a data link between my StartView and my Component Controller. I dragged the Username attribute from the right side (where the component is) onto my StartView context. The result looks like this.
And this is where I'm stuck: I don't know how to reference this username attribute from the Component to the ResultView. Obviously I need to create a datalink between the two but then what?
Basically I want to get this code working:
String headerText = wdThis.wdGetWelcomeComponentController().
wdGetContext().currentContextElement().getUsername();
wdContext.currentContextElement().setHeaderText(headerText);
// headerText is the name of the attribute that I want to create in the ResultView
Upvotes: 0
Views: 1139
Reputation: 1
As you pictures shown your context is in the controller, is the typical way on webdynpro, you defined that when you dragged the attribute to the view. You can confirm that by the arrow, and inside de properties of the view selecting the attribute, you'll see that is a WelcomeComponent attribute.
You can both create a new attribute in the new view al later join both attributes or just drag the attribute from the controller to the view to create a new one. The final result will be the same so I recommend you to create it directly thought controller, it got less steps.
If you chose to create a new one, when you will join both attributes (controller and view) webdynpro will force you to have a controller to view relation, you can’t make it reverse, based on de MVC pattern webdynpro implements.
If for example you got ant int attribute on view, and a string attribute on controller, when you make the relation controller attribute will remain, and view will change to string, through attribute definition is controller property.
Upvotes: 0
Reputation: 51
Create a mapping from username attribute (in component controller) to the headertext attribute (in the resultview). Normally for this, no coding is required.
Upvotes: 1