Browser/Javascript Communication [message #466305] |
Fri, 06 January 2006 02:35  |
Eclipse User |
|
|
|
After some looking, I see that the only way to communicate from the html
back to Java is this little trick:
boolean result = browser.execute("window.status=[javascript query here];");
...
and then get the text of the status.
I'm interested in embedding a javascript-based editor that will be working
with a lot of text. At some point I need to persist the information, so
I'd like to pass it back to Java to save in some manner. It doesn't seem
to me that depending on status being able to hold that information is
safe, especially with browsers constantly undergoing security revisions.
Has anyone found an alternate way to pass information about the html back
to Java?
|
|
|
|
Re: Browser/Javascript Communication [message #466365 is a reply to message #466327] |
Mon, 09 January 2006 09:50   |
Eclipse User |
|
|
|
Daniel Spiewak wrote:
> Unfortunately, I don't think there is a way since the Browser instance is totally separate from the Java code. As far as the html knows, it's running in a full-fledge browser. In other words, there's no way for the JavaScript code to get any sort of reference to the Java code that its browser is embedded within.
>
> I think your solution is pretty sound. I suggest that you profile your code a bit and find out how expensive the Browser#execute method is on average. If it isn't too bad, then set up an infinite loop (well, with an escape clause for stoppage) using Display#asyncExec(Runnable) to post to the event loop a call to the execute method. Depending on how expensive the call is, you could set a time delay on the loop (loop once, freeze for a quarter of a second, loop again). Hopefully the call isn't so expensive that you have to have a long delay (thus worse response time for the JavaScript editor persistance).
As I understand it, certain javascript engines allow for exensions to be
added to their runtimes. Could we not create an eclipse javascript
extension that allows javascript to perform calls out to eclispe? Does
the IE engine allow extensions? Does Mozilla's?
Just a thought.
|
|
|
|
Re: Browser/Javascript Communication [message #466715 is a reply to message #466305] |
Mon, 16 January 2006 00:14  |
Eclipse User |
|
|
|
Ivan wrote:
> After some looking, I see that the only way to communicate from the html
> back to Java is this little trick:
> boolean result = browser.execute("window.status=[javascript query here];");
> ..
> and then get the text of the status.
>
> I'm interested in embedding a javascript-based editor that will be
> working with a lot of text. At some point I need to persist the
> information, so I'd like to pass it back to Java to save in some
> manner. It doesn't seem to me that depending on status being able to
> hold that information is safe, especially with browsers constantly
> undergoing security revisions.
> Has anyone found an alternate way to pass information about the html
> back to Java?
>
You could make your (Java) application listen for a HTTP POST, then make your embedded browser post to it with a submit button on the html form.
|
|
|
Powered by
FUDForum. Page generated in 0.04526 seconds