cancel
Showing results for 
Search instead for 
Did you mean: 

How to simplify the code "workspaceroot" ALL the pages

Former Member
0 Kudos

See the image.... The path appears 13x in a small aplication...

1) is not possible to use a relative path to the index.html page?

2)is not possible to use a propertie in manifest.json to replace ALL instances?

3)is not possible to use the variable "data-sap-ui-resourceroots" defined in index.hmtl in ALL pages from App?

Accepted Solutions (1)

Accepted Solutions (1)

daniel_ruiz2
Active Contributor
0 Kudos

hi Ptharso,

I'm not too sure what you want to achieve or what openSAP Course is teaching  you.. but, this is sort of how it goes:

- in your index.html (or preview_hidden.html) you defined a namespace called "opensap.000_ApplicationFirst" and where to find resources on that namespace. This is mainly for requirejs, so you can have multiple namespaces (sort of a package concept) and modules and you can use a require afterwards.. it's just a smarter what of handling dependencies, would remind you of the import in many languages, and possibly a package concept of some other languages (for namespaces);

- while it's OK in javascript and UI5 to use something like opensap."000", on the majority of the cases you would never start an identifier with a number (I'm not even sure why they did this, it's plain horrible);

- considering this identifier is a 'string' you could assign the value of "opensap.000_ApplicationFirst" to any variable and use it afterwards, as long you have scope visibility;

- again, why would you do such? - this is an identifier, it should be something meaningful to qualify your module.. lets say you create a variable like window.app = 'opensap.000_ApplicationFirst', this would reduce the number of characters you type, but you still need to reference it everywhere... case you rename, you rename it everywhere.. so it doesn't matter it being a variable or a string in this case, because it's an identifier and not a variable 'per concept';

- why can't they "prefix" even more than the "defined prefix"? - well, they could, but this would be poor design because you may end up with several namespaces for different reasons.. they could add an override, which would help some people to type less, but this would be another "if" to be executed that could be avoided.. every if counts;

- "the names are big and consume bytes", usually this is true but you can use the variable thing I mentioned (perhaps window scoped) and when you minify the code it should become 1 or 2 characters.. this would save the bytes to be delivered over http.. does it help? - well, you would need to measure.. you would end up with a string concatenation (or perhaps an array.join) to create one string vs a few more bytes in a string directly.. - while a desktop has no problem to deal with this kind of stuff, every little thing you do to save operations on a device you should be doing - this goes to a simple "for var i versus array.forEach" or a "var that = this vs function(){}.bind" - when you code to target a device (which I believe you are) you need to be aware of all these little things, otherwise your application runs like crap (those sweet 30-40ms on a paint).


Case you want to learn more about this identifier which keeps repeating I suggest you read require.js documentation. In there you will find the why's behind it, the concept and probably you will also understand that there's not much to do about it.


Hope it helps,

Dan.

Former Member
0 Kudos

Dear Dan, you did not help .... the problem is simple ...

I just want to create a variable on the first page and refer that variable in the other pages.

So when you change the first page all others will be changed automatically.

I see that u did not understand the WHY of all this. See this figure and the workspaces!

The number(000,001....) of workspaces is JUST to order the course exercises OF THE WEEK.

Until NOW nobody has solved a simple  problem and show a solution to do this simple thing.

->Create a variable in the "index.html" or "manifest.json" and use on all other pages.

WHY is not relevant.... i need a help now to do this with an example!

Thanks for your attention. I hope you can help me.

Regards

daniel_ruiz2
Active Contributor
0 Kudos

Hi Ptharso,

"- considering this identifier is a 'string' you could assign the value of "opensap.000_ApplicationFirst" to any variable and use it afterwards, as long you have scope visibility;"

Create a variable on the first page and use it.. ? - What part you're having trouble?

Cheers,

Dan.

Former Member
0 Kudos

OOPs.... i had discover by myself...thanks for your attention

The solution was simple .... use this property ALL PAGES... and not necessary use more the name of the APP.... see the image

regards

daniel_ruiz2
Active Contributor
0 Kudos

hi Ptharso,

I sort of mentioned that.. you can use any identifier you want and the path to the resources.. also, just don't get too confused.. it's a "property" of some internal require.js loader, which in common name is a "module namespace". Whenever you do a require on something that starts with that string "raiz" it will look for a js relative to the path you indicated.

However my answer was about the concept of what you are doing, I really had no idea your trouble was just to rename the contents of the string..

Cheers,
Dan.

Former Member
0 Kudos

Hi, Dan

Simple...using the property defined in index.html i´m free of the name of application and can relocate  ALL parts the code to another folder! ... understand

A other reason is that i download the zip (export) from my Sap Ide, edit with dreamweaver and import to a another folder without problems.

The problem is solved....

Thanks for your attention...

Answers (1)

Answers (1)

SergioG_TX
Active Contributor
0 Kudos

Ptharso,

see if this blog can help with your issue?

it talks about the Component and manifest files and also how to set it up using the relative path.

in my case, i only saw it loaded once, I am not sure why on yours it loaded multiple times.

hope this helps!

Former Member
0 Kudos

No... i want to simplify more .... i think so is possible to use a word substitution in ALL pages lik this image below... i dont know how to do ... can you help me?

If you change the index.html  ALL the code will be correct...that´s what i want! thanks

SergioG_TX
Active Contributor
0 Kudos

Ptharso,

I think you may not be on the right path. please see these steps (which I followed on also shared with you on the previous blog.. . here is the official documentation

SAPUI5 SDK - Demo Kit

also, there is an openSAP course on how to develop UI5 apps currently in session - week 1 is happening now... i recommend you to enroll in it. .it is very helpful .  open.sap.com

good luck!

Former Member
0 Kudos

Laughts.... No problems Sergio....i´m doing the Sapui5 course now...

Try to understand why i´m looking for a solution to use a keyword like in this image to ALL pages of the code. I want modify the path only in the first page... Dont you understand yet?

I thank very much your attention and help to find the solution i want to do...