browser.loadString() timing problem

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

browser.loadString() timing problem

Postby stefanonafets » Mon Nov 28, 2016 1:05 pm

Hello,

in my application I use jcef to show pages generated by the app at runtime, using method browser.loadString(String html, String url); .

To do this I create a browser as follows: client.createBrowser("about:blank", OS.isLinux(), false);
than I call method browser.loadString("html content", "fake url");

I am facing a timing problem, in fact if I don't put a wait cycle between createBrowser and loadString, the loadString method doesn't have effect.
2 questions: is there a way to instance a browser passing HTML content instead of a String?
If not, how could I determinate when a browser instance is ready for submitting html content?

Thanks,
Stefano
stefanonafets
Newbie
 
Posts: 8
Joined: Fri Aug 12, 2016 12:07 pm

Re: browser.loadString() timing problem

Postby Czarek » Mon Nov 28, 2016 2:17 pm

Use data URIs as URLs: https://developer.mozilla.org/en-US/doc ... /Data_URIs
See CefLifeSpanHandler::OnAfterCreated.
Maintainer of the CEF Python, PHP Desktop and CEF C API projects. My LinkedIn.
User avatar
Czarek
Virtuoso
 
Posts: 1927
Joined: Sun Nov 06, 2011 2:12 am

Re: browser.loadString() timing problem

Postby sokolovAS » Tue Dec 13, 2016 2:05 am

"how could I determinate when a browser instance is ready for submitting html content?"
u can add callback on event "client load end"

Code: Select all
client.addLoadHandler(new CefLoadHandlerAdapter() {
@Override
            public void onLoadEnd(CefBrowser browser, int frameIdentifier, int httpStatusCode) {...}
}

and put there some thread synchronizer - simplest is volitile boolean flag, or countDownLatch
sokolovAS
Newbie
 
Posts: 4
Joined: Thu Nov 24, 2016 8:10 am


Return to JCEF Forum

Who is online

Users browsing this forum: No registered users and 11 guests