Quantcast
Channel: SCN : All Content - All Communities
Viewing all articles
Browse latest Browse all 3560

How to get value from Input Box.

$
0
0

Hi, Recently, I have been to learn SAP UI5.

 

I'd like to develop validation of ID and Password on login screen.

I can't get value from Input Box on sap.ui.getCore().getElementById.

 

If execute "sap.ui.getCore().getElementById", result was Undefined.

 

Please tell me how to get it?

 

I defined <Input id="user"... in view , but can't get value getElementById("user").

 

 

//Controller

 

sap.ui.define([

    "sap/ui/core/mvc/Controller",

    "sap/ui/model/SimpleType",

    "sap/ui/model/ValidateException",

    "sap/ui/model/json/JSONModel"

], function(Controller,SimpleType, ValidateException, JSONModel) {

    "use strict";

 

    var LController = Controller.extend("erpifview.controller.login", {

 

        onLogin: function(oControlEvent) {

            var user = sap.ui.getCore().getElementById("user");

            alert(user);  ----> Result was Undefined.

 

    return LController;

});

 

 

//view

<mvc:View xmlns:html="http://www.w3.org/1999/xhtml" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m" xmlns:sap.ui.core="sap.ui.core" xmlns:l="sap.ui.layout" controllerName="erpifview.controller.login">

 

...

 

        <Input

            id="user"

            class="sapUiSmallMarginBottom"

            type="Text"

            placeholder="Enter User ..."

            valueStateText="Name must not be empty. Maximum 10 characters."

            value="{

                path : 'login>name',

                type : 'sap.ui.model.type.String'

                }"

        />

 

...

 

        <Button

            text="Login"

            press="onLogin" />

 

//model

 

sap.ui.define([

    "sap/ui/model/json/JSONModel",

    "sap/ui/Device"

], function(JSONModel, Device) {

    "use strict";

 

    return {

 

...

 

        createLoginModel: function() {

            var oModel = new JSONModel({

                user : "hoge",

                pass  : "pass"

            });

            oModel.setDefaultBindingMode(sap.ui.model.BindingMode.OneWay);

            return oModel;

        }

    };


Viewing all articles
Browse latest Browse all 3560

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>