Jwrapper how to use in web application - jwrapper

I am trying to use Jwrapper to replace the java applet as chrome is blocking the Java applet.
So please suggest the best way to integrate the Jwarpper app in javascript and best way to deploy.
Regards,
Mukesh Gupta

When you build an app using JWrapper it will produce, amongst other files:
MyAppNameEmbed.js
MyAppNameExample.html
You can copy all the files in the build directory including the ones above and make them available on a web server / website.
You can then take the URL of the JS file above, and use the code in the example HTML file above to point it to your JS file. For example:
<script
id = "jwEmbed"
src = "http://www.example.com/myappname/MyAppNameEmbed.js"
showImage = "yes"
showAppName = "yes"
configuration = "offline*"
type = "text/javascript">
</script>
You can get the exact HTML code to use from your example HTML file in your build folder. This will create a block in your web page which autodetects the end user operating system and provides an appropriate download button which then links to the executable app files you uploaded (along with the JS and HTML files) to your website.

Related

Is including an iframe with a web extension considered remote code?

While submitting an extension to the Chrome Store this question is asked regarding remote code:
("All JS, Wasm or CSS that are not part of the administration package
are remote code. This also includes references to external processes
in tags, modules that refer to external personal and strings
determined via "eval ()".)
In the case of my extension I don't use eval(), or directly inject other scripts libraries, I just put an iframe that will have its own libraries.
Should I report this behavior remote-code?
Code to add the data
const iframe = document.createElement('iframe')
iframe.src = `URL STRING`
iframe.id = 'Frame'
document.body.appendChild(style)
document.body.appendChild(iframe)

vaadin external javascript file location

I've got several javascript files.
I want to import it on my page, created using vaadin.
I added annotation #JavaScript to my UI.
#JavaScript({ "prettify.js", "vkbeautify.js", "additional.js" })
I put it into VAADIN\themes\theme-name.
However when I try to run it
WARNING: prettify.js published by com.folder.ui.AdminUi not found. Verify that the file com/folder/ui/prettify.js is available on the classpath.
Where I should put it?
It depends.
For maven based projects, the script files belong under the resource folder.
Example: src/main/resources/com/folder/ui
For Ivy/Eclipse based projects, the scripts go in the same path as your class src/main/java/com/folder/ui
The maven based projects generally mess people up because all Vaadin docs are written for Ivy.
Hope this helps,
Malcolm

Flex Image Source Server Side Flash and Air

I'm trying to run my flex application in the air runtime instead of flash runtime. It seems to work perfectly except the images. Adobe Air runtime tries to load them. Is there a way to change the root adresses for Image to server side? If possible I'd like to use the same code for flash runtime and air runtime .. "single codebase ;-)"
var icon:Image = new Image();
icon.source = "images/test.png";
regards
cyrill
Typically I would simply package the assets into the AIR app. That way the relative paths would be valid both in the web app and the desktop app. However, since you pointed out in the comments that we're talking 10000 images you'll have to find another solution.
What you need is a variable that is configurable for each type of project. The final code to access your images should look like:
var icon:Image = new Image();
icon.source = rootUrl + "/images/test.png";
That rootUrl may be "" for the web app, and "http://www.mydomain.com" for the desktop app. Or it could be the absolute path in both cases. It doesn't matter: we don't want to hardcode that URL into our application.
Create a .properties file (or XML, or JSON; whatever configuration file you like) that contains the value for rootUrl and read that into your application model. This configuration file can be packaged into the AIR app.
A .properties file will look like this:
#myapp.properties
rootUrl=http://www.mydomain.com
For reading the file, you could use AIR's file streaming capabilities, but I suggest you load it the old-fashioned way with a URLLoader: this way it'll work both in the web and the desktop app.

ASP.NET Sound Resource not publishing

So I created an ASP.NET 4 application in VS2010, that needs to play sound to the end user, and it is working perfectly in my local development environment. The problem is the sound resource nor the Resources.resx is not being published to the server. Any idea why?
What I did:
1) Under Project  Properties  Recources I added my sound resource called: soundbyte (containing soundbyte.wav). I noticed this creates a Resource folder with the wav file and under my project a Resources.resx file referencing the file
2) In my code I play the file as follows:
Dim audioFile = My.Resources. soundbyte
Dim player = New Media.SoundPlayer(audioFile)
player.Load()
player.Play()
In the Visual Studio Solution Explorer right-click on Resources.resx and select Properties. Build Action. Set to content.
EDIT: The following resource might also help.
http://blog.andreloker.de/post/2010/07/02/Visual-Studio-default-build-action-for-non-default-file-types.aspx
Ultimately, I found a way to play the sound to the client browser (as opposed to the server the asp app is running on) was to follow the techniques in this example: http://www.vbdotnetheaven.com/UploadFile/scottlysle/PlaySoundsInASPX09032006083212AM/PlaySoundsInASPX.aspx
But I found an even better way in my case was to use Javascript, which doesnt' require the Resources technique.
simply embed the sound on the page after the tag:
<embed src="Sounds/jump.wav" autostart=false width=1 height=1 id="sound1" enablejavascript="true">
Then in javascript setup the function:
function EvalSound(soundobj) {
var thissound=document.getElementById(soundobj);
thissound.Play();
}
Finally play the sound in the browser as needed in Javascript:
EvalSound('sound1');

ASP.NET - Missing #includes cause compilation errors: Failed to map the path '...'

I have an ASP.NET application which features some server-side includes. For example:
<!--#include virtual="/scripts.inc" -->
These files are not present in my ASP.NET website project because my website starts in a virtual directory:
/path-to-my-application
When I choose Build Web Site, I get this error:
Failed to map the path '/scripts.inc'
Visual Studio cannot resolve these include files that are defined at the root directory level. They are not visible in the website project.
Aside from manually commenting out the #include references, is there any way I can get the website to build? Can I force Visual Studio to ignore those errors and compile the site?
Once the website is pushed out to IIS, there is no problem, because all the #include files are in place.
NOTE - Web Controls are not an option for this application. Please assume #include files are a requirement. Also, I cannot move the include files since they are used by other applications.
Can you make a copy of the includes files, place them in your solution on your dev machine and then tell VS not to copy those on build output (Build Action = None)?
If not, why don't you just hard code the entire link to the scripts.inc file (http://oursite.com/scripts.inc). Sucky work around, but I am pretty sure that you can't just ignore compilation errors (but yes to warnings).
Try using the ~/ syntax to represent the root of your app. e.g.
<!--#include virtual="~/scripts.inc" -->
try this:
Replace the SSI directive in your .aspx file with this:
<asp:Literal runat="server" id="scriptsIncLiteral" />
And put this in your code-behind:
protected override void OnPreRender(EventArgs e)
{
string scriptsFile = Request.MapPath(".") + #"..\scripts.inc";
scriptsIncLiteral.Text = System.IO.File.OpenText(scriptsFile).ReadToEnd();
}
You will of course have to change the number of ..\s if the scripts.inc file is located more than one directory up. You will also have to ensure that your ASP.NET web application has access to this file, otherwise you'll get a System.UnauthorizedAccessException.
You can set up a pre-build task in Visual Studio to copy include file in the project directory each time the project is built before the actual build. Although this is a hack.
A more correct way would be to set up a solution with two projects: one will represent your web-server's root directory/a set of the applications with which your project interacts (through including a shared file). Another will represent your troubled project. Then you should include (as in include as files into the project) your inc file(s) into the first project, for it to make them visible for a second project and allow it to include (as in server-side include in ASPX) them.
It is a way with more hassle, but it mirrors your situation much more closely, no hack, and can bring you some bonus features farther along the road (like easier intergration/representation of connected projects).

Resources