Detect click on a html link or button in JCEF?

Do not post support requests, bug reports or feature requests. Discuss CEF here. Non-CEF related discussion goes in General Discussion!

Detect click on a html link or button in JCEF?

Postby akshat » Wed Apr 23, 2014 6:51 am

I am creating a JCEF application.
Instead, running the MainFrame in windowed mode, I am using Full Screen Mode of Java.

Now, There is a Problem. Due to full screen mode of JFrame, I've no title bar, no close button.
Also, I don't want to add a control bar created using Java Swing.

So, How do I close the application?
Alt+F4 does not seem to work also!!

I was thinking, can I detect a click event on a HTML button using javascript in JCEF API?
So, I can close, application programatically?

In simple words, can we invoke Java functions using Javascript?

Sorry, if my question is so dumb. I've just started exploring CEF and JCEF!
:P
akshat
Techie
 
Posts: 14
Joined: Wed Apr 02, 2014 10:42 am

Re: Detect click on a html link or button in JCEF?

Postby magreenblatt » Wed Apr 23, 2014 10:39 am

akshat wrote:In simple words, can we invoke Java functions using Javascript?

Yes, see the "Binding Test" example using CefMessageRouterHandler in MainFrame. The general concept is described here: https://code.google.com/p/chromiumembed ... age_Router
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Detect click on a html link or button in JCEF?

Postby akshat » Wed Apr 23, 2014 11:03 am

The given example uses C++ code.
Will it work in JCEF also using CefMessageRouterHandler?

And, let me describe my whole implementation, that what I am trying to do.

I am using HTML/CSS/JS as frontend and Java is like my backend having all database and information.
So, I am using JCEF for displaying frontend.

Now, I want to get some data on frontend (JavaScript) side from backend (Java) side.
I was thinking, to use ajax for that or a RPC framework "Apache Thrift".

For that, I've to create a local server?

Can it be done without using ajax/thrift?
By using Java Bindings?
akshat
Techie
 
Posts: 14
Joined: Wed Apr 02, 2014 10:42 am

Re: Detect click on a html link or button in JCEF?

Postby magreenblatt » Wed Apr 23, 2014 11:15 am

akshat wrote:Can it be done without using ajax/thrift?
By using Java Bindings?

Yes.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Detect click on a html link or button in JCEF?

Postby akshat » Wed Apr 23, 2014 12:04 pm

I've successfully implemented it. Thanks.
It's like jquery ajax function, the "window.cefQuery" function, isn't it?

For a small application, this would work great.
But suppose, application is so big. And, there is so much variation in the type of data.
Like not only integers, strings but Objects, Sets, Lists.
That must be shared between both JS and Java.

That would a lot of work to do by using Message Router.

Apache Thrift has advantage in this section. Thrift provides "interface description language" through which it generates
code both for JS and Java. So any kind of datatype can be shared easily between them.

Apache Thrift uses Sockets to communicate between two application.
Do you think, we can make Apache Thrift use Message Router Handlers?
As, Apache Thrift is also doing the same work, "JS Thrift Client" sends a query and "Java Thrift Server" sends response to that query.
But, it has a protocol for sending information and it does through sockets.
akshat
Techie
 
Posts: 14
Joined: Wed Apr 02, 2014 10:42 am

Re: Detect click on a html link or button in JCEF?

Postby magreenblatt » Wed Apr 23, 2014 12:20 pm

CEF provides resource handlers for intercepting network requests (AJAX, etc), but that is not implemented in JCEF yet. Once it's implemented you can use XMLHttpRequest and handle the requests internally in the client without using a separate server.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to CEF Discussion

Who is online

Users browsing this forum: No registered users and 164 guests