I've created a browser using Javafx, which works fine to go to websites but I'd like to be able to do external protocols (ie: chrome:// or, if you are familiar with nexus mod manager, it launches it via the web using nxm://). I am essentially doing the same thing as nxm on my website, but I want to be able to use the client I have created. Simply typing something like nxm:// yields an about:blank page. Is this possible with jfx?
Edit: I was thinking I could check for a prefix at navigation other than http and https and launch it completely outside the browser?
Related
I need to make a web application in which there are two sites, A and B. A is like a control board with a lot of options, which will be open on a mobile device via a local server over wifi. Triggering the buttons on A should change the content on the Site B which is open on a computer in realtime. Much like a presentation but the two sites need to be different. What would be the best way to achieve this? I am a self taught programmer, with a basic knowledge of web technologies (HTML, CSS, JS, PHP, MySql) , processing and Java.
An idea might be like running ajax requests in certain interval on site B, that checks if there's any update from site A. And any action on site A is stored in a database or file. Then upon the triggered ajax request the script on site B makes a cURL request to get the stored update from site A and changes the content on site B accordingly.
My question is just as the title indicates.
I have a JavaFX app, and need to open a browser window. After opening it, I want to be able to communicate from the browser back to the app that opened it.
For example, if I opened the default browser window like this:
URI u = new URI(url);
java.awt.Desktop.getDesktop().browse(u);
Three options:
Through Javascript
Using javascript, and the window name you could access any window.
E.g. See: https://stackoverflow.com/a/16525481/1688441
Through Ajax Calls and a Server/Database
As another user answered, communication could be done with an intermediate server.
Third party library
The only other thing I can think of is using a 3rd party library to get the window within Operating System, though not much more I can suggest.
You can communicate back and forth with a WebView component. See http://docs.oracle.com/javafx/2/webview/jfxpub-webview.htm
If you are launching a page in the hosts browser, you'll need to develop a server based method to communicate.
I am currently learning JSP and Java Servlets. I was wondering if there is any way to call a java GUI from a JSP, not necessarily to load into the page, but to load onto the screen for database input. I am struggling trying to find some reference on how to do this on the net, but no luck so far.
You could use Java Webstart to start up the application on the client side. Or, ask the user to install a local client differently (like a daemon service).
The "GUI application" must have some kind of RPC (=remote procedure call) service running in background.
Once the client has your gui application installed, the JSP can invoke urls on http://localhost:port (ajax would help sending messages to the GUI application). The GUI application must have some rpc system (rest, webservice) that receives the requests from your web application (your jsp app) and start the GUI requested by the URL.
The problem here is to make sure the client has the port of choice available.
Another possibility is to register some URL to your application in the client side, so that when the user clicks a url like myapp://form/123 the OS automatically invokes your application to handle that URL. This kind of thing must be done differently per operating system. It's the way it works when you click on a magnet link or a skype://link. The procedure to register urls in the operating system is different per OS, you need to do some research (I never did that, but I am sure it is possible). You can also register a file extension to your app, and make sure that the specified extension is registered to your app. When the browser downloads the file and opens it, your app is invoked with the file downloaded as parameter (which will contain the instruction for your GUI). But most browser will not start automatically the app associated to the file after the download: again, you need to do some tricks on the client's operating system to make the "download and open" the default behavior for the browser.
I'm searching for a way to interact with different android browsers.
My intention is to get the URL of the website that is opened by the browser.
My app should run in background and give an alert when a specific url is opened, for now this is for testing and to learn more about android.
Is there any way to tell the browser to pass the url-string to my app everytime a new url is entered?
I've already got the idea to implement a local proxyserver wich checks all http-requests for a specific url, but is there a better way?
aditionally this should work with every browser not just the standard one but also eg. firefox or dolphin.
I already searched the last few days but couldn't find an answer....
Yes, you can do this! Check out http://seleniumhq.org/ for how to automate a web browser.
I'm remote controlling a Java application on a PC through an Android phone, and I needed my application to open a browser at the phones command, chrome in this case. I created a "Process" for chrome, opening a certain address. However, I need to be able to give tools on the Android phone for controlling the web page, such as scrolling. Can I programmatically send a command for chrome to scroll from my PC application containing the Process?
Sorry, it may have been unclear, but the only connection the android phone has to the program is through a socket. It is only used as a remote control for another Java application on a PC, which has its own screen.
I do not think that clean solution exists.
But I can suggest the following directions:
(1) try to investigate the native chrome API. If it has such ability call it with JNI.
(2) Try to use class java.awt.Robot. It allows to simulate user's activity, e.g. mouse clicks. Unfortunately it does not allow you to find any window outside your application, so it is a problem to decide where to perform the click.
(3) You can create proxy server and make browser you open to go to the target URL through the proxy. The proxy server will insert into the page your javascript that will communicate with server. The application that opens browser will send commands to server. The javascript that you inserted will receive these commands using AJAX and perform them. JavaScript can scroll browser window, so theoretically you can implement this.
If you can target the tab you want to control and edit the address bar you could send the command 'javascript:scrollTo(x, y)'. I just tested it on this page and it seems to work fine, replacing what I typed with the original address of the page.
Can I programmatically send a command for chrome to scroll from my PC
application containing the Process?
Not directly. What you could do is make some sort of web service that sits between the Android client and page that the Android client can send commands to and the page can periodically poll via AJAX calls to see what the client wants. That would be a clean DIY way that would work on other browsers besides Chrome.
You can use vnc viewer applications for that.
http://code.google.com/p/android-vnc-viewer/