I have a Java applet that runs with no UI and sends XML back to the calling Javascript for processing to a database. I have the applet set up to do a callback once the applet is initialized using an Init override and the callback is a Javascript function that proceeds to do some work with another applet method.
If the user clicks the "No" button on Java security warning however, no applet code is ever run and the calling page waits forever for the callback to occur. Is there a way to trap the user declining the security warning in Javascript?
Please no questions on why I'm using an applet for this, it's a very complicated infrastructure (out of my control) which involves multiple web vendors and this is the only architecture I've found that meets all the other requirements.
About the best you can do is poll for the applet appearance in JS, and if it doesn't appear after a 'length of time', pop an alert to the user offering to redirect to help (or wait - if they are still looking over the details offered by the security dialog/pop-up).
Use applets, expect trouble. Use hidden applets, expect chaos..
Related
Does a Java Applet always execute its code even when it losts focus? I've to put this applet in a web page.
I'm tryng to understand this cause i've to develop an applet that listen to some hardware components through JavaPos. I have a callback method defined inside the applet and i'm not sure if it works even when users click on other page component.
Thanks
Does a Java Applet always execute its code even when it losts focus?
Yes, unless of course the applet code intentionally stops execution on loss of focus.
Here's the overall flow of the use case:
User navigates to page with a third party applet
Another program sees that the browser URL has changed and fires a custom Java app that I have written.
That custom app needs to be able to call methods on the Applet
Is it possible to call the Applet from an application outside of the browser?
I've seen lots of questions and answers around calling applets from JS in the page, but that not the case here. That being said, however, if it were possible to inject JS into the page at runtime and have THAT make the call to the applet, that might be a workaround.
I know this is almost the same question: ask by Joe
I have a web application. When I close the window (clicking X on browser) it will call the Logout functionality.
The problem is when I open the web application and open the same web application on different window (new window or another tab). And close one of the window it will call the Logout functionality even if there is still an open window for that application.
What I want to do is, check first if there are other window that is using the same jsessionid with the current window I am about to close. And when I close that window, It will only call the Logout functionality if there is no window using the same jsessionid.
The standard way of course would be to have the login cookie expire at browser close and thereby log you out, but I'm guessing this is not an acceptable behaviour in your case?
AFAIK you can't access the content of another browser window unless that window was created using Javascript. Since it sounds like you're using onUnload handlers in Javascript, you could make use of those same handlers to keep track of your windows. It would lead to some overhead though and would not be full-proof (would not handle browser crashes or if the user navigates away from your app for example).
Pseudo-code: (this needs to be a mix of server-side code and client-side javascript since the load handlers are handled in Javascript and the session is server-side)
function OnLoad() {
if (document.referrer != "{identify your app here}")
Session("BrowserWindowsOpen")++;
}
function OnUnLoad() {
if ({your code for if window is closed})
{
Session("BrowserWindowsOpen")--;
if (Session("BrowserWindowsOpen") == 0 )
performLogOut();
}
}
I have a simple java applet that retrieves an image from a server and prints it out. The only problem is that I get the following java security warning:
Researching on this site and all over the web, some people suggest that I sign the applet (I tried that to no avail) and others suggest that I Modify a local java security setting but that isn't feasible for my clients.
Not only do I get this warning at the start of my applet, but seemingly any time the code attempts to interact with the printer, the dialog re-appears. Also, note that there is no checkbox next to 'Always allow this applet to access the printer'. These symptoms show on any browser.
How do I get java to respect the users choice to allow it to send jobs to the printer?
You might use the JNLP API services in a sand-boxed applet in a plug-in 2 JRE. They will still prompt the user each first time they go to print, but should also put an 'always allow' check-box on the dialog (though it really only applies for that run). See a demo. of the PrintService.
See also the applet info. page that includes a link on the Next Generation in Applet Java Plug-in Technology which "..brings new abilities to applets: such as .. allowing embedded applets to gain full access to the services of Java Web Start."
How do I detect when user closes(navigates away) or refreshes web page with JavaFX applet in it? I want to do some clean up in my code on those events.
Java Applet had some callback methods to do that, but how would I do it in JavaFX running in browser?
Two steps:
You may need to use a Javascript's window.onunload event to tell your JavaFX app to "close". If you do this, you can then
Add FX.addShutdownAction(myfunction); to your run() function. This will execute myfunction when your app is closed.
I don't have some complete code for you here, but I hope it's a start. You may not need to do step 1.