Skip to Content
avatar image
Former Member

Call XML View ui elements from controller

Hi,

I used to call and do operations on ui elements by accessing them from controller using below syntax.

this.getView().byId("txtid");

Most of the times , I am able to access UI Elements with above syntax and write validations as well but some times , it is not useful to read panel/tiles by using above syntax.

Are there any known restrictions/limitations in using above syntax?. Are there any alternative ways to call XML View UI Elements from controller,please suggest me.

Regards,

Koti Reddy

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

1 Answer

  • Best Answer
    Jan 05, 2015 at 02:10 PM

    My (personal) preference is to *never* access a view element by it's ID if you can avoid it 😉

    Although the SAPUI5 framework isn't a strict MVC framework, I try to stick to the MVC principles as much as possible, and this means the Controller should not call/reference items in its View(s).

    There are a few exceptions, but generally, using model binding you can almost always bypass the need for referencing controls by their ID's

    Add comment
    10|10000 characters needed characters exceeded