on 07-17-2013 7:50 AM
Hi,
I am trying to develop a simple mobile app that involves sap.m.input .I have gone through API references for the same but there is no api for reading data from input. My code is as follows :
sap.ui.jsview("myfirstmobile.MobileView", {
getControllerName : function() {
return "myfirstmobile.MobileView";
},
createContent : function(oController) {
this.setHeight("100%");
var flexbox=new sap.m.FlexBox({direction:"Column",height:"150px"});
flexbox.addItem( new sap.m.Input("un",{placeholder:"Enter UserName"}));
flexbox.addItem( new sap.m.Input("pass",{type:sap.m.InputType.Password,placeholder:"Enter Password"}));
flexbox.addItem( new sap.m.Button('login',{text:"Log In",
press:[oController.buttonClicked]}));
flexbox.setAlignItems("Center");
flexbox.setJustifyContent("Center");
var page1 =new sap.m.Page("page",{
title: "LOG IN",
icon: "http://www.sap.com/global/ui/images/global/sap-logo.png",
content:flexbox,
});
return page1;
}
});
Could you please tell me how to read data from input field in mobile application i.e.,username .
Hi Vijaykumar,
You can try something like this...
oInput = sap.ui.getCore().byId("un");
sValue = oInput.getValue();
Here is the link to the documentation
Cheers,
Ian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi guys,
I have tried these two methods its not working.My code is
sap.ui.jsview("myfirstmobile.MobileView", {
getControllerName : function() {
return "myfirstmobile.MobileView";
},
createContent : function(oController) {
this.setHeight("100%");
var flexbox=new sap.m.FlexBox({direction:"Column",height:"150px"});
//var un=
flexbox.addItem(new sap.m.Input("un",{placeholder:"Enter UserName"}));
var un=sap.ui.getCore().byId("un");
var unV=un.getValue();
flexbox.addItem( new sap.m.Input("pass",{type:sap.m.InputType.Password,placeholder:"Enter Password"}));
flexbox.addItem( new sap.m.Button('login',{text:"Log In",press:function(){alert(unV);}}));
//oController.buttonClicked}));
flexbox.setAlignItems("Center");
flexbox.setJustifyContent("Center");
var page1 =new sap.m.Page("page",{
title: "LOG IN",
icon: "http://www.sap.com/global/ui/images/global/sap-logo.png",
content:[flexbox]
});
return page1;
}
});
In alert box its showing blank even if I give some value in my user name field.
Regards,
Vijay.
Hi Vijay,
Move the following lines of code inside your button press event handler...
var un=sap.ui.getCore().byId("un");
var unV=un.getValue();
Currently you're calling getValue directly in createContent which is before it has any value
So it would look something like this...
flexbox.addItem( new sap.m.Button('login',{text:"Log In",press:function(){
var un=sap.ui.getCore().byId("un");
var unV=un.getValue();
alert(unV);
}}));
Regards,
Ian
JSBin Reference http://jsbin.com/ulifun/1/edit ... Check the output on the console... Only after submitting you would get the current value.......
Hi,
Thanks guys its working now.
regards,
Vijay.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
88 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.