I export a method to javascript window with JSNI, and I want to call this function from a applet in a GWT application..
I think that sometimes I have problems with Window context, so, I do some research and found the JSObject class.
I afraid with the package name (netscape.javascript). Is this class still be used? Is there another better way to do this?
I already tried to get applet context and show a new URl (with javascript:myFunction();), but, in some browsers it redirects the user to a new blank window...
What can I do to make it works best as possible?
Thanks in advance.
The netscape.javascript package is included with every Oracle JRE that I am aware of. Not entirely sure about the others.
Related
GWT code is a part of UI as an iframe. Now when the page is logged out, It should somehow call the gwt servlet code in the background and to invalidate the session. I have tried syncproxy, gwtrpccommlayer, But it didnt work since objects for the clients cant be created since it doesnt come under the gwt lifecycle.
Please suggest me how to achieve this. Thanks in advance.
Is it possible to capture the screen or generate a hardcopy in GWT programatically?
using AWT its possible but the AWT can't be used in GWT[only GWT not any other like smartGWT, ext-GWT]?
On client side GWT do nothing more than Javascript. So your question is: Can I take screen shot in JavaScript? The answer is:
If you want only take screen shot inside browser and can bear different you can use html2canvas.
If you want also take screen shot out of browser, you have to use other technology such as ActiveX control (may be Java Applet with AWT).
Check this: Take a screenshot of a webpage with JavaScript?
I don't believe that you will find anything native in GWT to do this. I believe that the best that you could manage would be something like this:
http://html2canvas.hertzen.com/
GWT just compiles java into javascript as it as been said by other guys in their answer. So you can look for a solution on the client but you can also do it on the server side.
One way to make it is to use phantomJS (which is a kind of webkit on the server) to rasterize the web page into an image on the server side. Could be really usefull to create features like "Export" etc
Phantom JS scree n capture
I have a difficult dilemma. I implemented a java application using Netbeans while implementing it I used JFrame and now I want to convert it to JApplet so that it can essentially function as a web service. I have lots of classes and I tried Changing JFrame to Japplet as directed in some solutions on this site but then new errors arise because of that... for example ... exit on close method not defined ... pack not defined and so on.
Could anybody give me a better solution.
Thanks a lot
Any help appreciated
..exit on close method not defined ...
An applet is a guest in a web page and might share a JVM with other applets. Exiting the VM is like 'burning down the guest house'. Instead call showDocument(thanksForUsingUrl).
..pack not defined and so on.
validate()
I have a page with a JS Function called test (e.g.), and, in one page of my app I have to open a Java Applet.
In google chrome, it opens as an embed element, and in firefox in an object.
Sometimes, in my applet, I have to call my JS function to do something in the page. I doing this with:
applet.getAppletContext().showDocument(new URL("javascript:window.test();"));
In browser that use the object, this code work like a boss, but, if it use embed, it do nothing, trowing a exeption in Browser console, saying that the Window does not have a "test" function.
I think thi is some trouble with embed context and document context, but I dont know how to fix it, or, if it is "fixable".
So, I like to know if is there any workaround to make it work.
thanks in advance.
I found the problem.
A minor update of chrome solve it. I dont know if the problem was in Webkit or in chrome itself, but, now it works.
Basically I want my Java Applet to simulate an url has been clicked, once a certain event listener has been executed.
Say, before I have a link in html:
<a href='destinationpage.php?pid=1001' target='rightFrame' />
I'd like to keep the same link to php intact, and when Applet actually invoke the click simulation method, the "target" attribute can also be used to control the behavior.
Similar SO thread found at here, but it doesn't have an answer.
I have little experience in this area, but I am okay with Java programming so long as someone can give me the suggestion of where to get started with.
Many thanks in advance.
Edit:
Okay, tried to get JSObject from the netscape.javascript package to work, added plugin.jar into CLASSPATH, unfortunately I finally got an ExceptionInInitializerError, so this approach failed, unless I can know how to debug in such a mess...
You could call the url directly in the applet but if you want to reference the link in the page something like the following should work. I have not tested this though.
getAppletContext().showDocument(new URL("javascript:function() {
document.getElementById('mylink').click();
}"));
}