04-01-2010 04:30 AM
Hi people,
working on widget javascript extension, I'm trying to execute some javascript from Java side, and it's ok.
In particular, I'm trying to load this javascript from a file.
In my class extension.example.loader.SampleExtension try to load the file javascript.js which is located under the same package (extension.example.loader) using getResourceAsStream:
this.getClass().getResourceAsStream("/extension/ex
This operation returning a null InputStream.
Is there any issue about compiling? Does widget packager remove not code file?
Thank you very much!
04-01-2010 12:00 PM
Hi Scarex,
You may want to take a look at the source code for the widget templates. It should give you an idea on how we are pulling out the embedded resources.
The full source code for the widget templates is in a "device_templates" directory in the Widget SDK install dir. This is the full Java Code that gets wrapped around BrowserField and runs a widget.
Cheers
04-02-2010 05:52 AM
Thanks tneil,
I looked in the code for a solution to my problem, but according to my understanding the found method (which use BrowserFieldRequest obejct) is related to resource packed in the widget itself (it should be declared in config.xml).
What I need is to load a text file attached to java sources used to compile the javascript extension; in other words I put this file in the source code under device_template folder trying to load it at runtime from java code.
Probably this is not possible...
Thank you very much.
Scarex
04-02-2010 07:21 AM
Yeah.. I don't think you will be able to include it as a resource the way you are trying.
You may have to simply include the contents of the .js file in a string variable in your code. Not nearly as flexible that way, but it may be your only option.