Skip to Content
Author's profile photo Chris Whealy

Data Binding in SAPUI5

Hi All

Here’s a tutorial I’ve written on Data Binding in SAPUI5.  This content will be integrated into the standard relase as one of the online tutorial when SAPUI5 1.30 is released later this year.

In the meantime, you can access this content as a stand-alone tutorial with an accompanying ZIP file containing the solutions.

SAPUI5 Data Binding Tutorial Document (Links to PDF document)

Solutions for Data Binding Tutorial Exercises (ZIP file)

This tutorial uses the Web IDE as the development environment and covers JSON models and Resource Bundles.

Regards

Chris W

Assigned Tags

      16 Comments
      You must be Logged on to comment or reply to a post.
      Author's profile photo Ekansh Saxena
      Ekansh Saxena

      Hi Chris,

      The link for the zip file is broken.

      Regards,

      Ekansh

      Author's profile photo Chris Whealy
      Chris Whealy
      Blog Post Author

      Hi Ekansh

      Oops!  All fixed now!

      Chris W

      Author's profile photo Ekansh Saxena
      Ekansh Saxena

      Yeah, Thanks Chris. It will be helpful.

      Author's profile photo Former Member
      Former Member

      useful example at the end. thank you Chris!

      Author's profile photo Syambabu Allu
      Syambabu Allu

      Covered with real examples....good document

      Author's profile photo Ajith Cheruvally
      Ajith Cheruvally

      Thank you so much!!!

      This is a very nice tutorial.

      Author's profile photo Jason Scott
      Jason Scott

      Hi Chris,

      Within your data binding example you explain the use of the "revealing module" pattern in JavaScript for declaring controller objects.

      I notice that in the tutorial code provided by SAP (official) for data binding (and others) they have skipped this and just return an object with all methods declared inline.

      Have you any idea why they have done this? Are the issues with the "this" pointer resolved by other means now maybe?

      Regardless of this issues which can be resolved with bind() for example; the flaw in *not* using the revealing module pattern is that methods within the returned object cannot call other methods in the same object...

      Regards...

      Author's profile photo Chris Whealy
      Chris Whealy
      Blog Post Author

      Hi Jason

      Yes, I used the revealing pattern because at the time I was developing the exercises, I needed two functions in the returned object to be able to reference each other.

      However, the document published in this blog was altered before being turned into the official training material because the coding example was altered.

      Yes, you can certainly get around the problem by using .bind(), but to me that is an example of where the developer must consciously add code that works around an ambiguity in the language (that ambiguity being JavaScript's flexibility of the meaning of this).

      To me, its a much more fault-tolerant style of coding to have a function return an object whose methods reference a closure (a.k.a. the revealing pattern).  That way, you avoid making the assumption that the developer consuming your object will just "know" that a bind() first needs to be performed.  (In the back of my mind here is Tony Hoare's comment that if the complexities of a programming language add to the complexity of the problem you're solving, then you're either using the wrong language, or your using the language wrong)

      As I understand it however, when you use the .extend() method inside sap.ui.define() to create your own controller or application etc., dependant objects should be created within same context as the object being defined, thus they should share a common definition of this.

      Regards

      Chris W

      Author's profile photo Jason Scott
      Jason Scott

      I agree with you Chris. It's a shame SAP chose to drop the revealing module pattern in all of its new tutorials. The extend() function does solve the 'this' issue but you can't call other methods within your module, which is an issue for all but the simplest modules and one that is quite difficult to debug.

      When creating formatter modules or similar that don't extend a standard control you'll have the "this" issue again as well.  😉

      Author's profile photo Hemendra Sabharwal
      Hemendra Sabharwal

      Simply Awesome, Thanks for sharing.

      Warm Regards

      Hemendra

      Author's profile photo Ramzi Abdallah
      Ramzi Abdallah

      Hi criss the link is broken ! may you give another one

      Author's profile photo Rafael Ferreiro Escalona
      Rafael Ferreiro Escalona

      Yes, the link to Solutions for Data Binding Tutorial Exercises (ZIP file) is broken...the other one works...

       

      Nice document

       

      Author's profile photo Chris Whealy
      Chris Whealy
      Blog Post Author

      Strange. The link to the solutions ZIP file works for me...

      Author's profile photo Rafael Ferreiro Escalona
      Rafael Ferreiro Escalona

      Now it works.....weird..... I tried a couple of times and I got the message that the link was broken.....(only for zip file).... in any case many thanks!!!!

       

       

      Author's profile photo Anindya Bose
      Anindya Bose

      Hi Chris

      This is awesome document.  This document says, there would be another document for OData , however I could not locate it . Can you please help ?

       

      Best Regards

      Anindya

      Author's profile photo Vladimir Kopytko
      Vladimir Kopytko

      Hi Chris

      The link to PDF document is broken.

      Regards,

      Vladimir