cancel
Showing results for 
Search instead for 
Did you mean: 

How to Pass Input Parameter from Object Page?

former_member593030
Participant
0 Kudos

Hello All,

I am using below link as an example,

https://sapui5.netweaver.ondemand.com/sdk/#/sample/sap.uxap.sample.ObjectPageFormLayout/preview

The input field is available in Simple form,

So When user give some value,How can I pass Value of Input field to my controller , so that I can send it Backend?

Thanks in advance.

Accepted Solutions (1)

Accepted Solutions (1)

0 Kudos

Hi Sujoy,

Oh i get it now :).

Try this:

var sValue = this.getView().byId(this.getView().byId(<blockid>).getAssociation("selectedView") + "--" + <your control id>).getValue();

in my case the control id is "Input" and block id is jobinfo
var sValue = this.getView().byId(this.getView().byId("jobinfo").getAssociation("selectedView") + "--" + Input).getValue();

In the example you shared Block ID is available in ObjectPageFormLayout.view.xml

The cleaner way of doing this is by using models.

check this example, much better: https://sapui5.netweaver.ondemand.com/sdk/#/sample/sap.uxap.sample.ObjectPageFormLayout/preview


Hope it helps.

Regards,

Vinod

Answers (3)

Answers (3)

former_member593030
Participant
0 Kudos

Hello vinodkannappa,

I have one Question regarding how to trigger controller here,

https://sapui5.hana.ondemand.com/#/sample/sap.uxap.sample.ObjectPageFormLayout/preview

Suppose

<Input value=" " maxLength="8" width="200px" showValueHelp="true" valueHelpRequest="onSearch/>


So how to trigger onSearch event in controller?

0 Kudos

You missed double quotes: try this.

var sValue = this.getView().byId(this.getView().byId("jobinfo").getAssociation("selectedView") + "--" + "STREETADDRESS1").getValue();

Regards,

Vinod

0 Kudos

Hi,

You can do it multiple ways:

Assign an id to your input control in the view and you can read the value in your controller as below:

In View:
<Input id="yourControlID" ......></Input>

Controller Code:
this.getView().byId("<yourControlID>").getValue();

Check documentation: https://sapui5.netweaver.ondemand.com/sdk/#/api/sap.m.Input/methods/getValue

You can also try binding a model to your simple form and bind a property to your input field.

As and when you enter the value in the input field, you model is updated and you can read the data by accessing the model in your controller.

Example with JSON Model: https://sapui5.hana.ondemand.com/#/sample/sap.m.tutorial.walkthrough.07/code (use getData method to read model data).

I quickly checked the example you are referring to, there is no model being used.

Regards,

Vinod

former_member593030
Participant
0 Kudos

Hello Vinod,

Thanks for the reply,

I have already tried this.

In View:<Inputid="yourControlID" ......></Input>

Controller Code:
this.getView().byId("<yourControlID>").getValue();

Problem is - Input field is another view and it is Simple form.(It is not part of Main view)

So When Save button is press, onSave action is triggered in Controller

this.getView().byId("<yourControlID>").getValue(); is getting failed.

Any Idea How we can get that?