Skip to Content

How to Pass Input Parameter from Object Page?

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.

Add a comment
10|10000 characters needed characters exceeded

Related questions

4 Answers

  • Best Answer
    Posted on Oct 16, 2018 at 12:19 PM

    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

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 16, 2018 at 11:29 AM

    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

    Add a comment
    10|10000 characters needed characters exceeded

    • 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?

  • Posted on Oct 16, 2018 at 02:38 PM

    You missed double quotes: try this.

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

    Regards,

    Vinod

    Add a comment
    10|10000 characters needed characters exceeded

  • Posted on Oct 25, 2018 at 09:00 AM

    Hello Vinod Kumar Kannappa,

    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?

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.