[sapui5] Cannot get control by control Id? See this post

Hello guys,

You maybe sometime frustrated when getting ID of controls of the sapui5 framework, I got the same problem too, when I was starting to work with sapui5.

The root cause that I found the most is forgetting declaring ID for the fragment. Because as sapui5 guideline mentioned, unlike View, Fragment's ID is not generated automatically by the framework. You have to do it by yourself when you initiate the fragment. If you forgot to do this, you won't be able to get the fragment (or controls inside it) using sap.ui.Core.byId() later.

Remember to use this line of code when initiate fragment:
sap.ui.core.Fragment(sFragmentIdsId)

But if you use other function, be aware of the order:
sap.ui.xmlfragment(sId, sFragmentId, oController)
Example:
this.oDialog = sap.ui.xmlfragment(
"createProcessDialog","com.HQ.app.test..fragment.CreateProcessDialog", this);
More details can be found here:
https://sapui5.hana.ondemand.com/sdk/#docs/guide/5da591c5a5a54740948acfe56b22fbc3.html


---V---

Nhận xét

Bài đăng phổ biến từ blog này

Tại sao lại chụp ảnh theo bố cục 1/3 ?

[sapui5] Best Practice in sapui5 development

Implement Search field with case-INSENSITIVE by SAP UI5