cancel
Showing results for 
Search instead for 
Did you mean: 

UI 5 and XSJS

0 Kudos


Hi HANA Experts,

                            I was trying to build a application where:

1) Users will enter a state

2) And application will return the list of customer in that state

I created a UI5 Application project in HANA Studio. Got the "index.html", the view and it's associated controller files. I then tried to call the data-base using the xsjs calls inside the controller. Like  $.db.getConnection() etc. The file got activated. However, it started giving errors when I tried to run from the browser. And I saw that system is unable to find ANY OF THE "$" FUNCTIONS OF XSJS. I saw that the XSJS library files are missing from the Project. So I manually added it to the UI5 application Project. But the error existed.

My question is:

1) How to call  "$.db.getConnection()" and other "$" functions from the UI5 application projects?

2) What's the technical difference between "XSJS" proejct and "UI5 Application" project?

3) When to use each of these Project types?

4) I now went ahead and created a "XSJS" project in HANA studio. The "$.db" functions started working. However the UI5 application libraries went missing. Does this mean UI5 is not compatible with "XSJS" services

5) If you can share me a sample code of using UI5 and XSJS, would be a good help

Your answers will be very much appretiated.

Regards,

Kowshik

Accepted Solutions (1)

Accepted Solutions (1)

thomas_jung
Developer Advocate
Developer Advocate
0 Kudos

You misunderstand what is executing where.  The .js files of the UI5 application are sent to the client side web browser and execute there.  Therefore they can't possibly execute the xsjs apis.  These only execute within the XSEngine within HANA on the server side.  You write your server side code in XSJS files and these create REST services.  You call these services from the client side within UI5 using jquery.ajax or the UI5 model object.

I would suggest that you install and study the example applications from the SHINE content:

http://help.sap.com/hana/SAP_HANA_Interactive_Education_SHINE_en.pdf

0 Kudos

Many thanks Thomas.....

Answers (2)

Answers (2)

0 Kudos

Gentleman,

                   So if I am building a Java based application on HANA...are you recommending to build 2 projects....One being a XSJS Project having all the XSJS services....and the other having all the UI based views and controllers.....

Ideally, I would like to have only 1 Project. Which should have both the XSJS services and the front-end  SAP UI based HTML pages.

I could see that it can be done in 1 single project:

I copied this and it's running fine on the HANA cloud trial instance.

Please share me your suggestions / recommendations and the best practice.

Regards,

Kowshik

sreehari_vpillai
Active Contributor
0 Kudos

while creating UI5 codes, it uses pure javascript coding. XSJS and Javascript are different. You can not write database connectivity and such server logic in UI5 project.

You create one xsodata/xsjs corresponding to your business logic and consume the same from your UI via OData model or ajax call.

Sreehari