cancel
Showing results for 
Search instead for 
Did you mean: 

Passing data from one view to another

Former Member
0 Kudos

hi all,

I have two views.One view is having name,age,city and address as input fields and one submit button.My requirement is that on click of button,user should see next view with all the entered details.I want to make use of context binding.Can anyone guide me how to proceed in this regard??

P.S: Points will be awarded.

thanks in advance

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi ankur,

As per your requirement, you can create a node say PersonalInfo having following context attributes in first view:

1. name type-String

2. age type-integer

3. city type-String

4. Address type-String

Bind all these attributes to respective input fields

Then you can first map this node to component controller using data binding(drag and drop graphical design view) and finally map the same node to second view from component controller.This way you can have the value entered in first view pased to second view.

for displaying the values in second view on click of button,you can use the following code:

bind you button to some action method and inside that method fire a plug to second view.

then in the init of second view wite the following piece of code:

wdComponentAPI.getMessageManager.reportSuccess(wdContext.currentPersonaliInfoElement.getName());

wdComponentAPI.getMessageManager.reportSuccess(wdContext.currentPersonaliInfoElement.getAge());

wdComponentAPI.getMessageManager.reportSuccess(wdContext.currentPersonaliInfoElement.getCity());

wdComponentAPI.getMessageManager.reportSuccess(wdContext.currentPersonaliInfoElement.getAddress());

Hope thi will help you.

thanks,

amit bagati

Answers (5)

Answers (5)

Former Member
0 Kudos

thanks amit and jhansi for detail explaination.I am done with my sample explaination.

thanks to others also...

i have rewarded points to all...

regards,

ankur

nikhil_bose
Active Contributor
0 Kudos

create attributes you need to pass in

first view controller,

component controller,

second view controller.

now, go to Navigation modeler : Add two views in the window, create out & in plugs.

go to Data Modeler view: create data link between 1st view - component -2nd view controllers and choose attributes you want to pass.

create an action for your button and assign values to the 1st view controllers or you directly map to UIElement data field.

if you want to hard code, you can use the code

wdContext.currentContextElement().setName("Ankur");

// before firing you should assign the values

wdThis.wdFirePlugOut();

nikhiL

Former Member
0 Kudos

Hi,

Follow the steps:

(1) Create the Three value attributes in Component Controller(Name, Age and City all of type String).

(2) You have two views and now open Data Modeler, and Create Data link between component Controller and first view. You can see the elements in component controller; Click that and drag to your view context( From Right to Left). Do the same to the second view controller.

(3) type this code in first view button action


wdContext.currentContextElement().setName( "name");
wdContext.currentContextElement().setAge( "age");
wdContext.currentContextElement().setCity( "city");
wdThis.wdFirePlugout();  //to navigate to second view

(4) type the code in init of the second view


String details = " Name : " + wdContext.CurrentContextElement().getName() +
" Age : " + wdContext.CurrentContextElement().getAge() +
" City : " + wdContext.CurrentContextElement().getCity();
wdComponentAPI.getMessageManager().reportSuccess( details );

Regards

Vinod V

Former Member
0 Kudos

Hi Ankur,

Below are the steps mentioned:

1. Create the following attributes in your component controller's context

name

age

city

address

2. Open your data modeler (Double clicking on your webdynpro component) and create a link between

view1 and component controller and drag and drop the context created in component controller to

your view1. Similarly create a link between view2 and component controller and drag and drop the

context from component controller to view2.

3. In your first view, bind the value property of the input fields for name, age, city and address with the

respective context attributes.

4. In your second view, bind the text view's text property for name, age, city and address with the

respective context attributes.

Regards,

Murtuza

Former Member
0 Kudos

Hi Ankur,

As you have the required context in View1 then do the context mapping from View1 to the Component Controller and from component controller to View2(where you want to display the details). Create an outbound plug from View1 and an inbound plug in View2 and map both the views.

In View1 create the input fields for name,age,city and address and a submit button. Bind the input fields to the respective context attributes. and create an action for the Submit button and fire a plug to the View2.

In View2 insert the different TextView UI elements and bind them to the context of View2.

Finally deploy and run th application which will give you the desired output.

Refer to the following application which clearly explains your requirement with the screen shots, you can just follow the same.

https://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/f64e7a90-0201-0010-e0b4-ec1f849e...

Thanks n Regards,

Jhansi Miryala