I have some SAPUI5 applications in one SAP server. All the applications will be deployed in an ERP Server Version 6.0.
All the applications has a access url in our ERP server that can be retrieved through the SAP NetWeaver. All the urls have the format commonPart/applicationName/index.html. All of these application will be accessible through a Fiori launchpad application.
Now I have a controller that has to be shared between all my applications. Is there any method that I can share this controller without copy and past?
Thanks in advance
You can create a reusable library project for SAP Fiori applications. Put your BaseController in that library. Then import the library in your application project and extend your application controller from BaseController.
Define library.js in root folder of your base project
sap.ui.define(["jquery.sap.global",
"sap/ui/core/library"], // library dependency
function(jQuery) {
"use strict";
// delegate further initialization of this library to the Core
sap.ui.getCore().initLibrary({
name: "mylibrary.reuse",
version: "1.0",
dependencies: ["sap.ui.core"],
types: [],
interfaces: [],
controls: [],
elements: [],
noLibraryCSS: true
});
return mylibrary.reuse;
}, /* bExport= */ true);
Declare the BaseController within it's JS file
jQuery.sap.declare("mylibrary.reuse.BaseController");
/** Controller Definition **/
Define and expose entry points to your library in neo-app.json
{
"routes": [{
"path": "/resources/mylibrary/reuse",
"target": {
"type": "application",
"name": "myreuselibrary",
"entryPath": "/mylibrary/reuse"
},
"description": "SAPUI5 Resources"
},
}
Then import the above library in application project, do JQuery.require() got BaseController and then extend it.
I hope this helps.
You could make a BaseController which has all of the functions that you want both controllers to have, and put this js file in a public/shared folder. Then, you can extend this controller from both applications.
you can simply type in the following
sap.ui.controller([your namespace].[controller folder name].[controller name]).[your method name]([parameters you want to pass])
for example
sap.ui.controller(CafApp.controller.create).onCreate(url);
Related
I'd like to use something that automatically labels images into an sap Fiori app. I found that Cloudinary has an add-on called Google Auto Tagging which should suit well for this purpose. So I followed this guide to use Cloudinary javascript SDK in my controller files of the webapp, and I installed in my PC the javascript SDK but then I'm not able to import Cloudinary library into my project.
I tried to create a zip with the "cloudinary-core" folder, imported it into my project and include "cloudinary-core.js", but I got the error Cannot read property 'Cloudinary' of undefined.
I also tried to include "cloudinary-core.min.js" which should be, from what I understood, the standalone minified version of the library, but had same error.
This is how I'm trying to import the library:
/* global cloudinary:true */
sap.ui.define([
"sap/ui/core/mvc/Controller",
"mdonamcve/libs/cloudinary-core/cloudinary"
], function(Controller, cloudinary) {
"use strict";
return Controller.extend("mdonamcve.controller.MainTable", {
onInit: function() {
var cd = new cloudinary.Cloudinary({cloud_name: "demo", secure: true});
},
...
};
}
I checked the path and it's correct, but "cloudinary" remains undefined.
Cloudinary SDK can be used for sap Fiori apps, right? Am I doing something wrong? Are there any alternatives to Cloudinary in case the latter doesn't work?
If Cloudinary doesn't use UI5's way of defining modules there is a high change that undefined is passed to cloudinary.
The global name of Cloudinary seems to be cloudinary. To not overshadow that just pass a slightly different name when defining your controller:
sap.ui.define([
"sap/ui/core/mvc/Controller",
"mdonamcve/libs/cloudinary-core/cloudinary"
], function(Controller, Cloudinary /* now with a capital C */) {
This way the globally available window.cloudinary (or just cloudinary) should also be available in your controller. Cloudinary (with a capital C) will still be undefined and can be ignored.
Reference: This blog.
Since you need to use a Cloudinary add-on which requires signing the request, this is to protect you from others abusing that add-on. The easiest solution might be to use the Upload Widget. You will need to also have an endpoint to one of your servers that signs the request before uploading. Everything should be documented here:
(https://cloudinary.com/documentation/upload_widget#signed_uploads)
When we have a stand alone app that has index.html we can have something like data-sap-ui-xx-supportedLanguages="en,de" in the bootstrapping part to determine which languages are implemented in our app. In this case we will not see anymore an error like this:
https://webidetestingXXX.dispatcher.hana.ondemand.com/webapp/i18n/i18n_en_US.properties 404
because we determined that our app does not support en_US!
How can I do the same in a Fiori type application, I mean when we don't have any index.html and it has only Component.js as the starting point!
I remember in the past we set that in manifest.json, but I am not sure!
It is mentioned under the chapter Supported Locales and Fallback Locale in this documentation: https://openui5.hana.ondemand.com/topic/ec753bc539d748f689e3ac814e129563
{
"sap.ui5": {
"models": {
"i18n": {
"type": "sap.ui.model.resource.ResourceModel",
"settings": {
"bundleName": "myapp.i18n.i18n",
"supportedLocales": ["de", "en"],
"fallbackLocale": "de"
}
}
}
}
}
This manifest.json configuration is only supported since UI5 1.77.
For lower releases there is apparently no application-level configuration.
This is an extract from manifest.json file of my overview application.
created using annotations
https://blogs.sap.com/2016/01/29/steps-to-create-analytic-card-on-overview-page-using-northwind-odata-service-v3-in-web-ide/
"sap.app": {
"id": "ovpdemo",
"type": "application",
"i18n": "i18n/i18n.properties",
"applicationVersion": {
"version": "1.2.2"
},
"title": "{{app_title}}",
"description": "{{app_description}}",
"ach": "sap",
It refers to SAP Support component which you need to use while raising bugs to SAP.
To be precise:
Application component hierarchy (SAP's component names for bug
reports); attribute is mandatory for SAP apps, but is not used so far
for apps developed outside SAP
Cited from:
https://help.sap.com/viewer/0ce0b8c56fa74dd897fffda8407e8272/7.5.6/en-US/be0cf40f61184b358b5faedaec98b2da.html
is it possible to configure the base directory of a sails app? At the moment everything is in the root './', but I want to use something like './server/'. So that every files and folders for sails are in that directory, e.g. config, views, controllers, api etc.
How is that possible? Didn't found a solution...
Best regards,
Kersten
You can use the appPath configuration option to set the path your app resides in.
There are a few different ways you could do this. One would be to pass in the appPath while lifting sails
sails lift --appPath=<path>
Another is to set the appPath in your .sailsrc file
{
"generators": {
"modules": {}
},
"hooks": {},
"appPath": "<path>"
}
I'm looking for a document with the possible metadata property names and config parameters for a component.
There are many documents on the internet with such definition. The question is how I know if the name of a property/parameter setting is a valid name.
metadata : {
name : "XXXXX",
version : "1.0",
includes : [],
dependencies : {
libs : ["sap.m", "sap.ui.layout"],
components : []
},
rootView : "XXXXX",
config : {
resourceName : "i18n",
resourceBundle : "XXXX",
serviceConfig : {
name : "main",
serviceUrl : "XXXXX",
}
}
There is a document available here which describes all possible metadata. Since there is no real assistance during design-time, you have to have a look in the API to check the possible values. If you want to extend it with your own properties/parameters, just make sure that the name is not too generic since the Component can be extended with each new version of UI5.
The approach of defining component metadata in the component itself has been superseded by an approach using a manifest file. You will find all available properties in the documentation .
The Component class extends the ManagedObject class and provides specific metadata for components. The UIComponent class provides additional metadata for the configuration of user interfaces or the navigation between views.
The metadata defined in component.js is common for faceless components and UI components. The following parameters are available:
abstract: Specifies if your component class is an abstract class that serves as a base for other components
version: Version of your component; this parameter belongs to the design-time metadata and is currently not used; it may be used in the future in the design-time repository
includes: Array of strings containing the paths to CSS and JavaScript resources for your component; will be added to the header of the HTML page and loaded by the browser. The resources will be resolved relative to the location of Component.js.
dependencies: Used to specify all external dependencies, such as libraries or components. Like the includes for resources that are added to the application’s HTML, the dependencies are loaded by SAPUI5 core before the component is initialized. Everything that is referenced here can be used in your component code right from the start. Specify here external dependences such as libraries or components, that will be loaded by SAPUI5 core in the initialization phase of your Component and can be used after it.
libs: Path to the libraries that should be loaded by SAPUI5 core to be used in your component
components: Full path to the components that should be loaded by SAPUI5 core to be used in your component
ui5version: Minimum version of SAP UI5 that the component requires; it helps to be ensure that the features of SAPUI5 runtime used in this component are available. As SAPUI5 currently does not enforce the use of the correct version, it is only used for information purposes.
properties: Defined for components in the same way as for a control or view
library: Specify the library the component belongs to
config: Static configuration; specify the name-value pairs that you need in the component
customizing: Customizing for components and views, see Extending SAPUI5 Applications
sap.ui.viewExtensions: Used for providing custom view content in a specified extension point in the standard application
sap.ui.viewModifications: Used for overriding control properties in the standard application
sap.ui.viewReplacements: Used for replacing a standard view with a custom view
sap.ui.controllerExtensions: Used for replacing a standard controller with a custom controller
for more Information go to the url:
https://sapui5.netweaver.ondemand.com/sdk/#docs/guide/0187ea5e2eff4166b0453b9dcc8fc64f.html
Well, from the code you could check if the property exist with the get(Property Name) method that all elementes have.
Otherwise all the properties ad hoc are in this url that Tim Gerlach shared for you before.
If it is a regular development approach, you should ideally look at the API of the component class.
If you are using metadata driven approach for development and you might generate the required code then you should fetch details from metadata information provided by the class or read it from .js file. ".js" will be helpful if you are not using SAPUI5 runtime.
Hope, this helps.
.........
Good Luck
Final answer has to be by looking through the source code as nothing else, even the API documentation, will be able to be 100% accurate against the consuming source.
As mentioned in the documentation, the definition of Component's metadata has largely moved to a separate file named manifest.json (aka. Application Descriptor).
With the introduction of the descriptor for applications, components, and libraries, we recommend to migrate the component metadata to the descriptor. [...] For more information, see Descriptor for Applications, Components, and Libraries.
Besides just looking at the list of available parameters in the doc, the closest "assistance" you could get is the Descriptor Editor from Web IDE.
The Descriptor Editor provides available choices, placeholder suggestions, and input validation.