Get css file from a projects resources folder into a widget
0
Hi Everyone, I was working on a widget where I have placed a custom.css file in MyApp > Resources folder. When I run the project, this file is available in MyApp > deployment > model > resources folder. In the widget, I am trying to get custom.css file from MyApp > deployment > model > resources by using JavaScript below; mx.server.get({ url: "model/resources/custom.css", handleAs: "text", load: function(response) { console.log("resource", response); }, error: function(e) { console.log("failed to retrieve resource"); } }); The above code is from Mendix api docs. I thought using mx.server.get, I will be able to get the css file from deployement/model/resources folder, unfortunately I get 404 (Not Found) error. If I change the URL to url: "styles/css/custom/custom.css" then there is no issues and I am able to successfully get the css file. Does this mean that I cannot access/read/get anything from deployment or in specific deployment/model/resources folder? (tried resources/custom.css path as well but no luck). Please can someone suggest if I am doing something wrong or weather this is achievable and if yes how can I achieve this? Thanks!
asked
Mohammed Siddiqui
3 answers
0
Hello Mo,
Since it's in a folder higher in the structure (model) rather than in "web" I would assume you need to navigate up.
Have you tried "../model/resources/custom.css"?
Hope this helps
answered
Dragos Vrabie
0
Try exposing a rest service with a string parameter representing a path relative to com.mendix.core.Core.getConfiguration().getTempPath(), use FileHandling.FileDocumentFromFile, store in a System.FileDocument, and expose on a rest service, then use that url