⬆️ ⬇️

Get access from java to javascript via swt browser

The hobbit or back and forth



Some time ago, I urgently needed to find possible ways to get variables from js and the browser in order to transfer their value in my application to java. Unfortunately, this question was not solved on Habré, or perhaps the power left me and the search is no longer so easy.

Anyway, today I will try to shed some light on this issue to some extent. So let's get started!



Task


In short, I will describe the situation - there is a certain application with the editor page, as editor we have a free NiceEdit . Why exactly the external editor - I needed to quickly build in the editor + the user data is presented as html and writing a bike would be quite silly. There were attempts to build a ready-made widget on swt, but either the project is outdated or the author has turned his head - the widget refused to work.

The main problem is that the user enters / edits the data in the editor, clicks the miracle button, and our application should receive what has just been written.



UPD

I will describe in more detail what the application is:

This is a standalone Eclipse RCP application in which user data is presented in html \ xml format due to circumstances. To create such data, view-ha was made with a browser into which nicedit was loaded and the user wrote there what he wanted. The problem was to get this data back to the application.



Decision


As it turned out, there is more than one solution to this problem:



Here are both ways that I know and used ... I will be glad to read new ideas and comments on the article. Thanks for attention.


')

Source: https://habr.com/ru/post/122758/



All Articles