4

Can someone explain in brief or re-direct me to appropriate link to understand the difference between core:view and mvc:view in XML view of SAPUI5/Fiori application?

When we start an application in Eclipse and create XML view using sap.m library we see core:view, but in sample applications in SAPUI5 SDK - Demo Kit, we are seeing mvc:view. Please help us understanding when to use what.

<core:View xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
  controllerName="splitapptest.Master" xmlns:html="http://www.w3.org/1999/xhtml">
  <Page title="Title">
  <content>

  </content>
  </Page>
</core:View>
1

2 Answers 2

13

The View control is in sap.ui.core.mvc: see Class sap.ui.core.mvc.View in the API documentation. Therefore, the namespace for a View element in an XML view definition is sap.ui.core.mvc.

This usually translates to something like:

<mvc:View xmlns:mvc="sap.ui.core.mvc"…>

but of course the prefix is arbitrary and you could just as well have:

<banana:View xmlns:banana="sap.ui.core.mvc"…>

The point is that it's the namespace that's important, at least technically. The confusion probably arises because the XML processor is rather lenient on the namespace specified for the root View element.

So to answer your question specifically, while core:View might be "correct" if you crazily specified xmlns:core="sap.ui.core.mvc", it would be very confusing, so the best way to express it is

<mvc:View xmlns:mvc="sap.ui.core.mvc"…>
0
1

You can try with:

<a xmlns:core="sap.ui.core" xmlns:mvc="sap.ui.core.mvc" xmlns="sap.m"
   controllerName="splitapptest.Master" xmlns:html="http://www.w3.org/1999/xhtml">
   <Page title="Title">
        <content>
    </content>
   </Page>
 </a>

it will also work. The declaration does not matter. XMLTemplateProcessor will not parse this element.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.