2 Replies Latest reply on Mar 3, 2013 7:57 PM by John Michael Vincent Rustia

    Fetch Html pages using AsyncHTTP.get

      Is it possible to fetch html pages from backend server using AsyncHTTP.get and on the controller callback, will insert the html text in the view/layout to be rendered?


      I think using insertAsyncPage API on javascript is available once I got the response.

      My goal is to fetch the jquery mobile pages using multipage template in one request, and insert it to the layout.erb of the rhomobile internal view. This way, the pages will be created on teh backend side and not on the rhomobile application. The rhomobile client application main purpose is to be able to provide the native capabilities of the device via Rhoelements API and use the motorolla webkit if needed.


      But I need exact answer if this is really possible?

        • Re: Fetch Html pages using AsyncHTTP.get
          Robert Galvin

          You could just have the Rho application do a Webview.navigate to your server. Then if you want to expose say 'Barcode' functionality, use our Javascript APIs on your web site code. You could check that it is a RhoElements client by looking at the userAgent string that can be customized in the config.xml:


                  <BadLinkURI               VALUE=""/>
                  <UserAgent                VALUE="Mozilla/5.0 (%p) AppleWebKit/%w (KHTML, like Gecko) MotorolaWebKit/%e Mobile Safari/%w" />
                  <ViewportEnabled          VALUE="0"/>
                  <ViewportWidth            VALUE="640"/>
                  <CaFile                   VALUE=""/>
                  <CaPath                   VALUE=""/>
                  <VerifyPeerCertificate    VALUE="1"/>
                  <NetworkCookieDatabase    VALUE="file://\Program Files\RhoElements\cookies.db" />       
                  <Cache                    VALUE="5MB" />        



          The AsyncHttp only lets you do a webview.navigate on callback anyways, because the page is already rendered. If the desired intent is to change the contents of the current page, then I would suggest doing the Async in Javascript and then just replace the contents of the DIV tag that you want to (which could be your HTML that you get from your server). You could use JQuery for the async and div replacement if you want to.

            • Re: Fetch Html pages using AsyncHTTP.get

              Given that I will be using WebView.navigate, how will be able to use Rhoelements API on our website code cause I believe I have to have the rho_javascript script to be included which is available only in the rhomobile client and not from the web server?



              One frustration I got developing with rhoelements, is the documentation doesnt say clear if other API in the matrix are available using enabled web application. In my theory, the api in the msi devices are readily available in the javascript when one is gonna use web server pages and not device internal views. Unlike in the other API which required rho_javascript_api.js, I believe even one copies the rho_javascript_api.js in the backend to include it as script in the pages, those API wont work anyway though the pages is running in a rhoelement enabled client application. Can you please make this clear for me, so just in case I need those API defined in rho_javascript_api, then at least I know I must use internal erb views. Is my theory correct???