cancel
Showing results for 
Search instead for 
Did you mean: 

How-To/Best Practice: create and implement custom libraries

Former Member
0 Kudos

Hi,

is there a way to write and use own libraries?

For example we will create an own UI5-Application with centralized functions of our company and we will consume this library in every UI5-Application we create.

Any ideas?

best regards,

Michael

Accepted Solutions (1)

Accepted Solutions (1)

AndreasKunz
Advisor
Advisor
0 Kudos

Hi Michael,

there exists a small code snippet showing how not only a control, but also a new control library can be defined on the fly:

http://jsbin.com/openui5-notepad-control-with-its-own-library-used-in-xmlview/1/edit?html,output

This enables the control e.g. to be used in XMLViews, as also shown in the example.

For a real control library you would put the library-describing part into its own file "library.js" and in the applications you would load the library by specifying it in the bootstrap script tag:

   data-sap-ui-libs='sap.ui.commons,sap.ui.ux3,my'

Per default it is then loaded from "/sapui5/resources/my/library.js". If the actual location is different, you can specify it in another attribute of the bootstrap script tag:

   data-sap-ui-resourceroots='{"my":"/other/location"}'

The library.js file and the controls will be loaded from there, then. (consider cross-domain restrictions!)

The control would be in a file called "Square.js" in the same directory as library.js. The css you should put into the file /other/location/themes/<themename>/library.css

Serious control library development inside SAP is based on the Maven-based build and further Eclipse plug-ins which to my knowledge are not published (both are complicated and under-documented, that's the reason, not because we don't *want* to publish them). They would take care of minimizing code, generating a preload file containing all controls, in order to have less requests at runtime, generating a right-to-left version etc. All for optimization, but all not mandatory.

Regards

Andreas

Former Member
0 Kudos

Hi Andreas,

Suppose I want to make/customize a control, where in I want to add html elements to a chart and which will be displaying some values from the odata/ json.

I want to use viz charts. But as if now I am using onafterrendering of the chart to append elements. Is there any standard way to do this while rendering ?

Or I have to create new library?

Regards,

Naren L Naik

Answers (1)

Answers (1)

ChandraMahajan
Active Contributor
0 Kudos

Hi Michael,

I guess you are talking about developing reusable sapui5 components. if yes then refer this thread discussion and

Regards,

Chandra

tswami67
Explorer
0 Kudos

Hi Michael, I would like to write an IDLE time logout after 10 minutes to all my applications. once logout, redirect to home login page. So I would to write a java script code and share this code across to my custom sap ui5 applications. This is my idea. Please let me know if better than this? thanks advance.

Best regards

Swami