|
Rank: Advanced Member Groups: Member
Joined: 7/7/2014 Posts: 60
|
We need to do some postbacks on a web page once it is loaded.
The current process is:
1. get the URL 2. create a Request with that URL and add in some custom headers 3. webview.LoadRequest(request)
Now after the request has been loaded and displayed, we need to do a post back to a specific controller/action and retrieve the data returning.
I.e., the current site after loading is somesite.com; we need to call somesite/controller/action and get the results back.
Is this possible?
thanks!
Edit: the browser control has authenticated against the URL so it will need to pass on the credentials as well to be valid. The iOS version of this program does a postback to @controller/action so is already authenticated; we need to duplicate this process in the Windows launcher.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
You will need to do this in your web page through JavaScript. For example, you can use JavaScript to modify the form's action attribute and then call the form's submit method. Once you have the correct JavaScript code, you can use webView.EvalScript to call the code. This will cause the WebView to post back the page to wherever you want it to post back.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 7/7/2014 Posts: 60
|
In that case, is there a way to get the webview credentials so I could post directly? For this particular operation, javascript is currently not an option at the moment.
Or the cookie - if I can get the cookie I should be able to pass that cookie along with a separate web request.
The way we're doing this on iOS (if I understand it correctly) is that the iOS Safari browser loads the page, but the launcher then creates a hidden iframe for that page and can process the controller actions via an HTTP postback from that iframe. I don't think that is an option within the EO browser - we don't have the ability to create additional frames or anything.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi, You can capture the cookies by handling this event: http://www.essentialobjects.com/doc/6/eo.webbrowser.webview.afterreceiveheaders.aspxInside this event you can examine e.Response.Cookies to get all the cookies EO.WebBrowser receives from the server. Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 7/7/2014 Posts: 60
|
Turns out we already had a javascript wrapper in the web client be able to call controller actions. So your answer was already implemented. I just did not look into the iPad specific javascript stuff (the iPad wrapper does a LOT more to deal with the smaller screen and Dragon Speech stuff and screen navigation; the Windows launcher not nearly as much)
Thanks!
But I may still look at your response as well.
|
|
Rank: Advanced Member Groups: Member
Joined: 7/7/2014 Posts: 60
|
The javascript call is asynchronous. I've added the event handler for script handling:
webView1.ScriptCallDone += webView1_ScriptCallDone;
The method never gets hit so far. I am rechecking the make certain I've got the correct syntax and all that for the call.
My question is: will ALL javascript calls get this event? Because I have several in there (all synchronous) and that method never gets hit.
thanks as always!
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Hi,
No. ScriptCallDone is only called for script run through QueueScriptCall. Because QueueScriptCall only queue up the script to be executed later, ScriptCallDone event is provided so that you can notified when the script is actually executed.
Thanks!
|
|
Rank: Advanced Member Groups: Member
Joined: 7/7/2014 Posts: 60
|
thanks - I am now using that and a few other things. We got it working the way we needed to. Essentially we did update the web client to have navigation events for the async javascript. Process (for anyone who may want to know): 1. call the async java script with an ID passed along 2. the web service processes the call, on done it creates a navigation request 3. we get the request in the BeforeNavigate event, check to see if it is a postback via a special URL, and if so, kick off another request via QueueScriptCall with the call to load the results back (there is a hash dictionary with our ID basically) 4. the ScriptCallDone then loads the data for the item with our ID
It was an interesting experience, but the web architect made the framework so that now the Windows launcher has all the same API calls as the iOS launcher. iOS just handles the async javascript results differently.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,196
|
Thank you very much for sharing. I am glad that you got it to work. Please feel free to let us know if there is anything else.
|
|