Page 1 of 1

phonegap and profoundui

Posted: Tue Jul 31, 2012 8:55 am
by chris_rover
how do I get any data from phonegap to profoundui ?
I know how to get phonegap to interface with the device, but how do I get the information back to profoundui.

Re: phonegap and profoundui

Posted: Tue Jul 31, 2012 11:48 am
by Alex
You should be able to use any Profound UI JavaScript API, like pui.click() or changeElementValue(), from PhoneGap.

So, for example, let’s say that you have detected the Native Android Back Button in PhoneGap and would like to send a corresponding message to the RPG code. You can use the following code in PhoneGap:

Code: Select all

if (getObj("BackButton") != null) pui.click("BackButton");


Then, on any screen where you want to handle the back button, add a hidden link or button with the id of "BackButton" and bind the respond to RPG variable "BackButton".

In your RPG code, simply test for it as follows:
RPG CODE
If BackButton = *On;
  // your logic for back button goes here
EndIf;
Other device information can be sent in a similar manner as well.

Re: phonegap and profoundui

Posted: Tue Jul 31, 2012 3:37 pm
by chris_rover
Thanks for that reply. however, my main task is to get any data(for example geolocation coordinates) from phonegap into perhaps a set of variables in Profoundui. That example could help us to plot a position on google maps. or say we want to read a barcode using the device camera(like what LANSA's LongRange can do), how can we get that data sent back to profoundui?

Re: phonegap and profoundui

Posted: Tue Jul 31, 2012 3:56 pm
by David
As Alex mentioned, any of PUI's JS APIs should be usable from PhoneGap. So, you should be able to use "changeElementValue()" to put information into the screen.

See here:

http://www.profoundlogic.com/docs/displ ... +value+%29

To use this, you just pass the "id" property of the widget you want to change (exactly, including case), and then the value you want to put into it.

The widget could be a hidden field.

After changing a field on the screen with this, you can then use "pui.click()" to return control to the server:

http://www.profoundlogic.com/docs/displ ... %28+id+%29

You can pass a button widget's "id" property to a simulate click on that button (i.e. to set on a response indicator in RPG), or without parameter to simulate enter key press.

The RPG application then receives the data in the field bound to the widget you have changed through scripting, just like it receives any other bound field data.

Does this explain it?

Re: phonegap and profoundui

Posted: Tue Jul 31, 2012 5:12 pm
by chris_rover
ok here's our scenario:
We have a phonegap application loading a external profoundui page into an android webview. we are trying to communicate between the profoundui app and the android/phonegap application. we acheived communication by adding a javascript interface to the android webview which loads our own java class as javascript available to our profound page. this works when getting info from the device to profoundui and vice versa. e.g with geolocation coordinates.

However this approach is too OS specific. We need to be able to access phonegap functions directly from our profoundui external page without the use of the android functions to grab information like location coordinates. We need to use phonegap functions and maintain OS portability.

Thanks for the reply. Hope my explanation was clear enough.

Re: phonegap and profoundui

Posted: Tue Jul 31, 2012 6:38 pm
by Antonio
Hello Chris,

I think the following link will help you with what you're looking to do.

http://www.profoundlogic.com/docs/displ ... pplication

It seems you are trying to use a webview inside an android application created with phonegap to access your external profound UI application. However, you can create a native android application with profound ui through phonegap, as the example shows.


However, for the geolocation issue, you could alternatively look into HTML5's geolocation API to solve your problem.
http://dev.w3.org/geo/api/spec-source.html

Let me know if this helps.