Show TOC

File Names and Locations (View and Controller)Locate this document in the navigation structure

In SAPUI5, controllers and views are defined and instantiated via a name that equals a SAPUI5 module name within the require/declare concept.

By default, all files have to be located in a subfolder of the resources folder of the Web application. If this location is not appropriate, deviations can be configured as described in the following example:

The following example assumes that your views and controllers are located on your local machine where the SAPUI5 runtime is loaded from another machine. When you instantiate a view or a controller, SAPUI5 runtime loads them in relation to the resources folder of the machine where SAPUI5 runtime was loaded. To inform SAPUI5 runtime that your views and controllers are located on your local machine, use the following code:, sURL);



It is usually sufficient to use sap.ui.localResources which internally registers sModuleNamePrefix to the URL "./" + sTransformedModuleNamePrefix, where all dots are replaced by slashes in the transformed name. All files starting with sModuleNamePrefix will then be loaded in relation to the location of the HTML page that called sap.ui.localResources.

If your files are located at http://<localhost:8080>/<myapp>/, for example, you can use registerModulePath as follows:"myapp", "http://<localhost:8080>/<myapp>/");



All views and controllers with a name starting with myapp, for example myapp.MyView, will then be loaded from your local machine.