Hi,
I am trying to pass the value in a text box to another view but the getValue function is throwing an error, please refrer to the following code:-
view.xml
http://www.w3.org/1999/xhtml">
controller
onPress : function(oEvt){ var oInput = sap.ui.getCore().byId("id").getValue(); var oLabel = sap.ui.getCore().byId("label"); app.to("idfirst2"); }
the content of the view is as follows:
<content>
<Input id="id" type="Text" > <
/Input>
<Button text="Submit" press="onPress" ariaDescribedBy="defaultButtonDescription genericButtonDescription">
</Button>
</content>
Thanks Jun for your response, but I would still want to know how to get the value from UI control. The id of the input control is "id" and the code i am writing on controller is
sap.ui.getCore().byId("id").getValue();
and the error I am getting is : Cannot read property 'getValue' of undefined
core can only work with the real id. if you check with browser dev tool, you will find that ui element is not with id "id"
in the view controller, you can use this.byId("id") to get reference to the ui element.
Hi,
First get reference of the view and then get the control reference in the view. (you cannot directly access the control reference as at runtime all "id" are prefixed with view id)
Below is the code in controller
var oView = this.getView(); var sControlId = oView.createId("id"); //this creates id with prefix eg: __xmlview1--id var sValue = sap.ui.getCore().byId(sControlId).getValue();