Page Is Blank Without Throwing Any Errors

Your root view is missing a root control such as sap.m.AppAPI which: Writes a bunch of properties into the header of HTML document, e.g. the viewport meta tag, Writes height: 100% to all its parent elements.[src] Without a root control, the content will be displayed improperly. Hence, adding an <App> should be sufficient in your … Read more

How execute code every time that I view a page

There is a solution for you. There is a event called routeMatched when navigation is triggered every time. You can attach the event in the detail page. onInit : function () { this._oRouter = sap.ui.core.UIComponent.getRouterFor(this); this._oRouter.attachRouteMatched(this.handleRouteMatched, this); }, handleRouteMatched : function (evt) { //Check whether is the detail page is matched. if (evt.getParameter(“name”) !== “detail”) … Read more

Binding in Control with “class” Attribute

UI5 doesn’t support binding for class in XML view directly as it’s not a valid property of ManagedObject. Nevertheless, there is a workaround by adding custom data: Add CustomData with the property writeToDom to your control. Use your expression binding there: <ControlXYZ class=”myControl”> <customData> <core:CustomData xmlns:core=”sap.ui.core” key=”green” value=”foo” writeToDom=”{= expression}” /> </customData> </ControlXYZ> Depending on … Read more

Add a New Item to a Table / List

Bind the collection of data to the <items> aggregation of table. Add a new entry to the model (instead of to the UI directly) when the user clicks on Add. Thanks to the aggregation binding, UI5 will create a new ColumnListItem for you and you did not break the MVC pattern. Here are some examples, … Read more

getBindingContext() returns undefined

getBindingContext(sModelName?) Get the binding context of this object for the given model name. If the object does not have a binding context set on itself and has no own Model set, it will use the first binding context defined in its parent hierarchy. You have given name to the model (this.setModel(oModel, “myModel”)). Specify the model … Read more

Global Model Not Accesible

Avoid setting models on the Core directly if you’re using Components. Components are meant to be independent and reusable parts and therefore will not inherit the Core models by default. Models should be set depending on your business case: Models declared in the app descriptor (manifest.json) section /sap.ui5/models will be set on the Component. They … Read more

How to Access Elements from XML Fragment by ID

Accessing controls inside a fragment depends on how your fragment was created in the first place. Here is a list of cases with respective API to use to get the control reference. Given: this as a reference to the current controller instance Fragment required from the module sap/ui/core/Fragment <MyControl id=”controlId”/> in the fragment definition API … Read more