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.
Related
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..
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."
I am truly struggling with this - i have checked all of the other Stack overflow pages and while this may seem like a duplicate question there are NO other answers I can find anywhere besides potentially using multiple modules (even though this does not seem correct)
All i want to do is have a set of static pages making up a website for my main page, the Login page (i plan to use RequestFactory to pull back the user permissions to display stuff for the app from here - somebody suggested in another post such as this to do it from a "Non-GWT" page - that doesn't sound correct to me), and then when the user logs in successfully he gets directed to the actual app with certain things being displayed based on his current permissions.
Now, i have implemented little test projects with multiple JSPs to do redirects using Window.Location.replace("...") but then I have no idea how to actually populate that particular page with what I want to be replaced.
From just 1 GWT app is it possible to have a full web page in static HTML files (or even JSPs i don't care), a Login Page, and the actual App.
And if this is so, How do you do this?
I use RootLayoutPanel.get() to load up my main App - how does it know which RootLayoutPanel to actually use - i've spent hours fighting with this and a lot of the tutorials / answers to the questions don't provide much depth as to how to actually go about implementing anything. There is obviously something i'm just missing
I want to do something exactly like the example in the showcase: https://www.blueworkslive.com/#!gettingStarted:overview
If you use chrome and check the tags every single page on there says GWT 2.4, so it's definitely not like one answer i came across saying "don't use GWT for the login". This seems like it should be something simple that I just... am not finding or honestly am not getting from any of the examples.
This is close to the last step of my project and any help on this would be greatly appreciated.
I'm using Apache Shiro with GAE, Objectify for a database and RequestFactory - there is only one main html page and the app is simply calling getRootLayoutPanel to load the app. not sure if any of that is useful.
implementing the page isn't the issue it's just the redirecting
To login on GAE, via Google account or federated login, you need to redirect your user to login page. Since you run GWT, which usually only has one page, you have two choices:
Do the normal redirect to login page - in this case browser will go to login page and you will loose GWT app state. After login, you can be redirected back to GWT app. As said - GWT app state will be lost. This is the simple way.
Open the login page in child window or iframe. Set destination URL to a page that closes the window (actually it must install a javascript parent hook, that destination page calls). When login is done, destination page calls JS hook, which notifies parent page thet login procedure is over, closes the child window/iframe and continues. This is more complex, some login pages do not like iframes (in case of OpenID login), but it retains your GWT app state.
To answer your question:
Yes it's possible to have multiple pages in a GWT project (GWT pages/modules and static files). Of course, as you navigate from page to page, you will loose app state. GWT module is only "active" as long as page is loaded in browser.
I've implemented an interactive map applet, which is embedded in a web application. The application uses some Ajax, but has a predominantly page based structure.
The problem is, navigating away from and back to the page containing the applet causes an applet reload, which takes several seconds.
Possible ways to alleviate this problem I thought of are:-
Make the applet run continuously in a separate browser window (I lose integration with the main web app though)
Convert the web app to use Ajax exclusively to avoid page reloads
Implement the map view as a standalone desktop app
If there is some way of preventing applet reloads in the browser I would be very interested to hear about it, but I don't think this is possible due to the applet lifecycle.
I think that you enumerated all options, their advantages and disadvantages.
I'd like to suggest you a combination of options you suggested.
You can separate you applet into 2 components. First, heavy-weight application that will be started using a java web start. It will contain all application logic and will run in minimized (or even transparent) window. It will prepare image and send it via network to light-weight applet that just shows it.
I this case you do not loose your application integrity: map is shown in browser. The applet is very light weight, so it starts fast. The stand-alone app implements the most of programming logic.
Here is how to make window transparent: http://java.sun.com/developer/technicalArticles/GUI/translucent_shaped_windows/
i want two use output from one applet as an input for another applet running in parallel..
There is no problem to run as many as you want applets simultaneously on one page. But you wish to make applets communicate with each other.
Each applet can access applet context that has API to access other applets on the page:
applet.getAppletContext().getApplets()
applet.getAppletContext().getApplet("appletName")
Then you can call any public method you want.
Like AlexR said, you can run all the apps you want(as long as CPU can handle it). Another 2 options for communicating between them would be
1: To use the 'Model-View-Controller' Design Pattern described in the book "Advanced ActionScript 3 with Design Patterns."
2:Create an Applet that will Encapsulate all the other applets, then with this applet start up all the other applets. Inside each applet declare an instance of each (applet)class you need it to communicate with then create a set method for it. now from your Encapsulating class use the set methods to pass the instances of the applets to each applet that needs it....(yes, I know it's confusing but it works well if you get it right)