“onBeforeRendering” or “onAfterRendering” is not called every time the view is opened

Why (…) is the onBeforeRendering not triggered every time the view is displayed? I think there is a misconception of what “rendering” means. In UI5, when a control is “rendering”, its corresponding HTML element is being modified or created in the DOM by the RenderManager. I.e. onBeforeRendering means literally “before the render function of the … Read more

How to handle the itemPress of sap.m.Table?

This really seems to be a frequent issue people face when they use sap.m.ListBase related controls. Let me give you an overview on how to manage the events (and particularly activate them at all): The confusion could be related to the sap.m.ListMode of controls inheriting from sap.m.ListBase and the sap.m.ListType of items inheriting from sap.m.ListItemBase. … Read more

Property Binding: How to Concatenate String Literals and Binding Value

To enable complex binding syntax, the recommended way is to add the bootstrap configuration option compatVersion with the value “edge”. E.g. in index.html: data-sap-ui-compatversion=”edge” This replaces the need for sap-ui-xx-bindingSyntax since “edge” sets the binding syntax automatically to “complex”. Adding bindingSyntax makes only sense if the compatVersion is lower than “1.28”. Options with xx should … Read more

Difference Between this.getView().byId(), this.byId(), and sap.ui.getCore().byId()

Difference between this.getView().byId and this.byId Take a look at the source code of the this.byId method: // sap.ui.core.mvc.Controller Controller.prototype.byId = function(sId) { return this.oView ? this.oView.byId(sId) : undefined; }; As you can see, this.byId is just a shortcut for this.getView().byId. They both can be used to access controls defined in the view. E.g.: <!– Given … Read more

What is the EventBus in SAPUI5 for?

EventBus in UI5 is a tool with which we can leverage publish-subscribe pattern in our app. How do we get EventBus? Currently, there are two APIs which return their own instance of EventBus: Globally: sap.ui.getCore().getEventBus(); for Standalone apps. Component apps and their container app where developers have control over both. Component-based: this.getOwnerComponent().getEventBus(); // this == … Read more

Live Update the Number of Items

Client-side Models If a client-side model such as JSONModel is used (i.e. assuming all the data are already available on the client) and if the target collection is an array, a simple expression binding is sufficient: title=”{= ${myJSONModel>/myProducts}.length}” Sample 1 (ClientModel): Updating count after deleting items from sap.m.Table Sample 2 (ClientModel): Updating count after filtering … Read more

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