gwtp - How to program at client side to get Html Snapshot (or to capture all texts) of entire GWT page? -


to let understand want, please read this:

suppose have gwt page (mydomain.com#!article). page contain many widgets , data downloaded db. db data & widgets mixed each other, example label can hold customer name (customer name came db).

so, on page javascript, ie when view source can see javascript. however, if open gwt page in chrome & save "mygwtarticlepage.htm" local pc, reopen "mygwtarticlepage.htm", can see text, widgets... in "mygwtarticlepage.htm" same ones in "mydomain.com#!article".

now, right-click & view-source of "mygwtarticlepage.htm", see not javascript text, & db data & widget still in there.

so, "mygwtarticlepage.htm" called html snapshot of "mydomain.com#!article".

are clear?

now want program @ client side able capture texts of "mygwtarticlepage.htm".

so, myarticlepresenter.java (in client package) should work this:

private asynccallback<getarticleresult> getarticlecallback=new asynccallback<getarticleresult>(){     @override public void onsuccess(getarticleresult result) {         string articledata=result.getarticledata;         //... many other data db .....          mylabel.settext(articledata);         //... many other widgets settext of db data ....          // should here html snapshot of "`mydomain.com#!article`" ??      } } 

note: people can use htmlunit, htmlunit work @ server not @ client package. besides, htmlunit couldn't parse gwtp page properly. gwtp gwt app buit under gwtp framework.

i hope can me ask question.

client code, definition, has run on client - in case of gwt or html/js app, means in web browser.

htmlunit is web browser, 1 never renders screen. can still ask html contents of current page. entirely written in java, runs in jvm, including server. consider phantomjs, headless chromium - can script take screenshots, export html, etc. native app, you'd need right build server, , you'd need wiring call phantomjs.

htmlunit should work gwt, when configured. gwttestcases default use htmlunit run gwt tests in browser without launching 'real' browser instance. of course, htmlunit must run in normal jvm, server running on.

that said, can't call client code directly, instead launch html/js (compiled gwt/java) page in htmlunit browser.

another detail consider - speed. if interested in being indexed search engine, speed important 2 reasons. first, search engine hitting these pages quickly, , don't want server killed when google/yahoo/bing drives , downloads urls can find. second, among other things, server may take speed of url being finished account when ranking page.

  • dev mode slow because of calling , forth between js in browser (even htmlunit) , real java. since compiling app js anyway, there no need use dev mode on server
  • pre-loading pages: consider running htmlunit periodically , generating plain html pages can served right away when requested. if data doesn't change often, work you, , fastest of all, if page pre-rendered , cached.

finally, if using gwtp, crawler service, appears designed filter our urls encoded fragments , translate #! tokens, pass gwtp application. see https://github.com/arcbees/gwtp/wiki/crawler-support more details.


Comments

Popular posts from this blog

how to proxy from https to http with lighttpd -

android - Automated my builds -

python - Flask migration error -