cancel
Showing results for 
Search instead for 
Did you mean: 

Can any one please tell me the difference between js and xml views in SAP UI5?

Former Member
0 Kudos

I Just want to know why this differences for XML view and Js view ?

Accepted Solutions (1)

Accepted Solutions (1)

karthikarjun
Active Contributor
0 Kudos

Hi Mandakini,

XML views are preferable. Because it is easy to run on low configuration device.

And Its rendering time is less compare to other views.

More over we can add extension points to extend/add new controls .

Thanks,

Karthik A

Answers (5)

Answers (5)

karthikarjun
Active Contributor

Hi Mandakini,

XML Views

Js Views

HTML Views

JSON Views

XML  Views are declarative and is the cleanest approach to built a UI.

It prevents too much logic to being added in the view.

Js Views aren’t declarative.

It can be developed fast.

HTML Views are also declarative.

Using sap.ui.core.plugin.

DeclarativeSupport

UI are defined as element.

JSON views are meant for mock data.

Controls in Declarative Views(XML,html) will be converted into Javascript controls internally when app is being executed.

In  Javascript view conversion will not happen since we are creating the Controls in Javascript directly.

Controls in Declarative Views(XML,html) will be converted into Javascript controls internally when app is being executed.

HTML can already be embedded into XMLViews.

But here events can’t be binded in view definition.

Easy to parse inside the tools like WEBIDE.

Hard to parse inside the tools.

Easy to parse inside the tools like WEBIDE.

Thanks,

Karthik A

sivakumar_mobility
Active Participant
0 Kudos

Hi reddy,

I am also a fan of JS based views. Possible (dis)Advantages are in my eyes:

Advantages for JS

  • Object oriented creating of the view. You can create objects, arrange them, call methods on them and use any JavaScript function you want (e.g. loops)
  • For my taste, SAPUI5 XML based view seem to be a little too implicit. In JS, I can cleary read out of the coding what I am doing.
  • Pages can be dynamic
  • You stay in JavaScript all the time

  Disadvantages for JS  which is advantage in XML:

  • XML favours a strict seperation between view and logic. Your are forced to use external formatters for example. I think XML views might be cleaner.
  • SAP ships all Fiori apps using XML views. So, you are a little forced to have atleast the knowledge in how to read XML based views.
  • You might have less lines of code in XML

XML disadvantages:

  • bad readability
  • modifying existing views is trickier at times
  • quite implicit, bad if you care about what is happening behind the scenes

I hope above explanation will give you better understanding to you.

with reagrds,

siva.

Message was edited by: sivakumar M

sivakumar_mobility
Active Participant
0 Kudos

Hi reddy,

As per my concern javascript is light weight and flexible.But XML view is heavy weight.

All foiri apps are made up with xml view. so you better to practice XML view.

if you dont know both choose js view. because lot of developer there to help you and also fast.

Note: small application means choose js view.

         Big application means choose xml view.

Message was edited by: sivakumar M

Former Member
0 Kudos

Hey

Different ways to define your UI (JS/XML/HTML views) are available so that one individual can use the one he/she prefers.


With XML views it is easier to tell which UI components are part of another UI component than with JS views, since XML views are well formed and structured. 

With JS views you have a bit more freedom to go wild, since you can create functions and such in your view. Using XML views you are kind of forced to define your functions (that you attach to your view components) in the controller.  This helps, if you don't know what should go in the view and what should go in the controller. Using XML views  are the preferred way to go. If you are new to UI5 and you  want to look at some coding examples of certain UI controls in https://sapui5.hana.ondemand.com/explored.html the views are likely to be XML view files.

Regards

ChrisSolomon
Active Contributor
0 Kudos

Besides the obvious, XML view is typically preferred by MVC purists as it keeps the view "uncluttered" and enforces "separation of concerns".