cancel
Showing results for 
Search instead for 
Did you mean: 

How to pass input parameter values from one view to another?

vivekbhoj
Active Contributor
0 Kudos

Hi Everyone,

I have created two views.

In first View, I have created panel to get input parameters and now I want to pass these input parameter values to my second view to perform other operations using the input.

How can I achieve this?

Regards,

Vivek

Accepted Solutions (1)

Accepted Solutions (1)

former_member182650
Contributor
0 Kudos

Hi Vivek,

I think you could use this options:

Option 1. View parameter routing:

Documentation/AdvancedTopics/Navigation – SAPUI5 Wiki (TIP CORE User Interface)

Option 2. Global model (cross-view):

Documentation/AdvancedTopics/DataBinding/UsageInApp – SAPUI5 Wiki (TIP CORE User Interface)


sap.ui.getCore().setModel(oModel);

Option 3. JSViews. viewData param. Please refer to:

https://sapui5.hana.ondemand.com/sdk/docs/guide/MVC.html

JsDoc Report - SAP UI development Toolkit for HTML5 - API Reference - sap.ui.core.mvc.View

In my opinion, the more elegant/polite option is no. 1

Hope this helps,

Kind regards

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi Vivek,

Just have a look to the following explanation.

in first view:

1. you can create one object .

[ var myObject ={};]

2. put the values from ur fields into that object.

[

myObject.name = sap.ui.getCore().byId("fieldId").getValue();

]

3.bind that object to a modelname.

[

sap.ui.getCore().setModel(myObjet, "modelName");

]

4.get that object from model in 2nd view as:

[

var myObject1 = sap.ui.getCore().getModel("modelName");

]

Now you can get all the fields and values from myObject1 as:

[

var name1 = myObject1.name;

]

Hope this will work.

Cheers

Gouri

former_member210252
Contributor
0 Kudos

Hi Vivek,

If you are looking for passing parameter value from one view to other view using Webdynpro then follow the below steps.

1. Create a Inbound plug for View2. ( Because you are passing value from View1 to View2)

    While creating inbound plug - in the parameter section define the parameter name and data type of it

     which is similar to the one passing from View-1

2. Create a outbound plug for View1 ( Because you need to pass values of View1 to View2). Here define

   parameter and data type which you want to pass to View-1

3. Establish navigation link for these  plugs created.

4. Assume on Button Click value from View-1 to be passed to View-2 then use the below code

   wd_this->fire_to_<<outboundplug>>( parameter = value).

   Here parameter is like MATNR = '1000001' etc . Here you can use the field whose value needs to be passed to other view.

Regards,

Rafi

WouterLemaire
Active Contributor
0 Kudos

Hi,

The way to pass data from one view to anther view depends on your way of working. If you are using the router component, you could use that for passing data like already mentioned.

But If you are working like the Fiori-like ui: http://scn.sap.com/community/developer-center/front-end/blog/2014/03/04/building-sap-fiori-like-uis-...

You could pass the data while navigating:

  1. var bus = sap.ui.getCore().getEventBus(); 
  2.                     bus.publish("nav", "to", {  
  3.                               id : "SecondView"
  4.                               data : { input : sap.ui.getCore().getModel("model").oData.input } 
  5.                     }); 

For example: http://scn.sap.com/community/developer-center/front-end/blog/2013/11/15/sapui5-project-setup-for-beg...

Another way for passing data is using a globel model, like and mentioned:

http://scn.sap.com/community/developer-center/front-end/blog/2013/11/15/sapui5-project-setup-for-beg...

Hope it helps!

Kind regards,

Wouter

Former Member
0 Kudos

hello ,

You have to create output plug in the first view with export parameters ( like Input to pass )  then , an inbound plug in the second view with ( input parameters )   , now you have to link the outbound plug of the first view with the inbound plug of the second view , this can be done at the window level , where the views are embedded ,

to passe the input parameters to the second view from the first view , you just have to fire the outbound plus of the first view , with parameters to pass ( one you create the plug , the wizard can do this for you ) use navigation section in the wizard

Hope it will help you

Regards

HK

Qualiture
Active Contributor
0 Kudos

Use a model which is shared across your views SAPUI5 SDK - Data Binding