Skip to Content

How to pass values from view.js to controller.js

Dec 08, 2016 at 05:26 PM


avatar image
Former Member

In my view.js, I have two text fields -- inputName and inputComment. I have a Submit button. When the Submit button is pressed, I want to pass the Name and Comment values to the Controller.js. I have tried everything I can think of but nothing works.

var oButton = new sap.ui.commons.Button({

text: "Submit",

press: function() {

oController.onSubmit.apply(oController, {

inputName: oName.Input.getValue(),

inputComment: oCommentInput.getValue()



How can I pass inputName and inputComment to the onSubmit function in the Controller?

Maybe someone can share their code on how they pass Input values to a function.



10 |10000 characters needed characters left characters exceeded
Former Member

I got this to work but I think there should be a better way where I can use the parameters inputName and inputComment that are passed with oConroller.onSubmit.apply.

onSubmit: function() {

var name = sap.ui.getCore().getElementById("inputName").getValue();

var comment = sap.ui.getCore().getElementById("inputComment").getValue();

* Please Login or Register to Answer, Follow or Comment.

0 Answers