Correct way to use window.cefQuery

Having problems with building or using the JCEF Java binding? Ask your questions here.

Correct way to use window.cefQuery

Postby ramyakrishnan » Fri Oct 09, 2015 9:53 am

Hi ,

I am trying to use the CefMessageRouterHandler in my application to send some msg back and forth between JS and Java. I created a JS as shown in https://bitbucket.org/chromiumembedded/java-cef/src/8e7fc7e3d4934ffbb7c080c129b264e6db963ea9/java/tests/detailed/handler/binding_test.html?at=master&fileviewer=file-view-default ( I copied the window.cefquery block but changed the "onFailure part" .. I also implement the onQuery in my Java side to handle this request. However, I get Uncaught TypeError: undefined is not a function error on the line where I specify window.cefQuery. Am I missing something ? Should I do some other step for this to work ?

JS side
window.cefQuery({
request: 'CLOSING',
onSuccess: function(response) {
console.log(response);
},
onFailure: console.log("Error ")
});

Java Side
@Override
public boolean onQuery(CefBrowser browser, long query_id, String request,
boolean persistent, CefQueryCallback callback) {
if (request.equals("CLOSING")) {
callback.success("I have no idea y this wont work");
return true;
}
// Not handled.
return false;
}


I jus get the "Error" message along with the undefined error.
Thanks
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: Correct way to use window.cefQuery

Postby magreenblatt » Fri Oct 09, 2015 11:14 am

ramyakrishnan wrote:JS side
window.cefQuery({
request: 'CLOSING',
onSuccess: function(response) {
console.log(response);
},
onFailure: console.log("Error ")
});

Your onFailure value is not a function.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Correct way to use window.cefQuery

Postby ramyakrishnan » Fri Oct 09, 2015 11:21 am

I tried keeping it like this as well :

window.cefQuery({
request: 'CLOSING',
onSuccess: function(response) {
console.log(response);
},
onFailure:function(error_code, error_message) {
console.log(error_message);
}
});


and in Java i wrote
@Override
public boolean onQuery(CefBrowser browser, long query_id, String request,
boolean persistent, CefQueryCallback callback) {
System.out.println(request);
if (request.equals("CLOSING")) {
callback.success("I have no idea y this wont work");
return true;
}
callback.failure(1, "Still not working");
return false;
}
I still get the same error :( "Uncaught TypeError: undefined is not a function" at window.cefquery line
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: Correct way to use window.cefQuery

Postby magreenblatt » Fri Oct 09, 2015 11:53 am

Does it work if you run the JCEF sample application?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Correct way to use window.cefQuery

Postby ramyakrishnan » Fri Oct 09, 2015 11:58 am

No ,even in the example i got the same error.
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: Correct way to use window.cefQuery

Postby magreenblatt » Fri Oct 09, 2015 12:05 pm

ramyakrishnan wrote:No ,even in the example i got the same error.

What JCEF version are you using? On what OS?
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Correct way to use window.cefQuery

Postby ramyakrishnan » Fri Oct 09, 2015 12:09 pm

Jcef version is 3.2~ ( sorry i donno the specific version but sure that its above 3.2 ) and the OS is Windows 7. Even when i jus load the page in a chrome browser, i get the error Uncaught TypeError: window.cefQuery is not a function..
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: Correct way to use window.cefQuery

Postby magreenblatt » Fri Oct 09, 2015 1:35 pm

ramyakrishnan wrote:Jcef version is 3.2~ ( sorry i donno the specific version but sure that its above 3.2 ) and the OS is Windows 7. Even when i jus load the page in a chrome browser, i get the error Uncaught TypeError: window.cefQuery is not a function..

Where did you get the JCEF build from? window.cefQuery will only exist in a properly build JCEF application.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm

Re: Correct way to use window.cefQuery

Postby ramyakrishnan » Fri Oct 09, 2015 1:39 pm

I got it built from here :https://bitbucket.org/chromiumembedded/java-cef/downloads

I saw the java class where the configuration for cefQuery is made and there is no change from that and what is present in the bitbucket website.
ramyakrishnan
Mentor
 
Posts: 62
Joined: Wed Sep 16, 2015 12:21 pm

Re: Correct way to use window.cefQuery

Postby magreenblatt » Fri Oct 09, 2015 2:33 pm

ramyakrishnan wrote:I got it built from here :https://bitbucket.org/chromiumembedded/java-cef/downloads

That link doesn't provide a built version. See the BranchesAndBuilding Wiki page for build instructions.
magreenblatt
Site Admin
 
Posts: 12409
Joined: Fri May 29, 2009 6:57 pm


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 130 guests