Embedding scripts for widget

Answered
0
0

I’m trying to bundle/embed the sources for a widget control as embedded resources in WiseJ.

Instead code like this:

widgetLeaflet.Packages.Add(new Widget.Package { Name = “leaflet.css”, Source = “https://unpkg.com/leaflet@1.7.1/dist/leaflet.css” });
widgetLeaflet.Packages.Add(new Widget.Package { Name = “leaflet.js”, Source = “https://unpkg.com/leaflet@1.7.1/dist/leaflet.js” });

 

I want to use these files as embedded resources like and host them within my application:

widgetLeaflet.Packages.Add(new Widget.Package { Name = “leaflet.css”, Source = “resource.wx/leaflet.css” });
widgetLeaflet.Packages.Add(new Widget.Package { Name = “leaflet.js”, Source = “resource.wx/leaflet.js” });

After embedding these files as embedded resources it seems they still can’t be loaded !?
Btw. must these files be configured as “Embed resource” at build in the Resources folder ?

Is there a way to make this work ?

Thank you.

 

  • You must to post comments
Best Answer
0
0

Please ignore this topic. After thinking a little more about it, the better way to do I think is just to place the files to the project and reference them like this:

widgetLeaflet.Packages.Add(new Widget.Package { Name = “leaflet.css”, Source = “js/leaflet.css” });
widgetLeaflet.Packages.Add(new Widget.Package { Name = “leaflet.js”, Source = “js/leaflet.js” });

  • You must to post comments
0
0

Hi Tobias,

Deploying the files as you would with a traditional HTML system is the right approach especially with complex widgets that use their own javascript loaders, relative resources in css, etc.

But to answer your original question, this is the correct way:

  • Place the resources in /Resources or /Platform
  • Uncomment the WisejResources attribute in AssemblyInfo
  • Reference like this “resource.wx/[AssemblyName]/Namespace/file. i.e. “resource.wx/MyApp/MyApp.Resources.leaflet.js”.

See also https://docs.wisej.com/docs/concepts/embedded-resources.

The [AssemblyName] in the URL is optional. If you omit it, Wisej will look for the file in all assemblies with [assembly:WisejResources]. And you can always override embedded resources by deploying the same file structure on the server.

Additionally, Wisej has a way to “inject” the “resource.wx” also when using complex systems in order to make everything work as a single assembly (in some cases it’s impossible and you have to deploy the files).

There are many examples and extensions that you can use as a guide on GitHub.

See https://docs.wisej.com/examples/https://docs.wisej.com/extensions/

HTH

  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.