NetTalk Central

Author Topic: Get variables back from Java  (Read 4693 times)

lkeyser

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
    • Email
Get variables back from Java
« on: October 23, 2017, 05:11:29 AM »
I'm just using to geolocation as an example for my question.
I can see the the values returning in the console of NT, but i don't know what I am doing wrong to retrieve the values back to the two local variables, in this case the longitude and latitude values.

GET /SetSessionValue?_Latitude_=-28.662680899999998&_Longitude_=23.853461&_Altitude_=0&_Accuracy_=30&_AltitudeAccuracy_=0&_Heading_=NaN&_Speed_=NaN&_LocationUnixTime_=1508764130&_LocationDate_=79192&_LocationTime_=4733027&_LocationError_=&_ajax_=1 HTTP/1.1

I have include a small example.
Thanks
Regards
Louis
Clarion 10
NT10

 

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Get variables back from Java
« Reply #1 on: October 23, 2017, 11:57:27 PM »
Hi Louis,

I'm not sure what you're trying to do in the example - or where you've put code etc.

When I run it, what am I looking for - what are you hoping to accomplish, and so on?

cheers
Bruce

lkeyser

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
    • Email
Re: Get variables back from Java
« Reply #2 on: October 24, 2017, 01:04:25 AM »
Hi Bruce

I'm trying to get the variable values back from java script.

How do I "extract" the java return value "_Longitude_" and place it in my own session value for example.


Regards



lkeyser

  • Jr. Member
  • **
  • Posts: 69
    • View Profile
    • Email
Re: Get variables back from Java
« Reply #3 on: October 24, 2017, 03:47:11 AM »
Hi
Attached a new sample.

Got it working kinda, but I'm pretty sure I'm doing it wrong. Have to click the button a few times to get the parameters to return.

Regards



Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11250
    • View Profile
Re: Get variables back from Java
« Reply #4 on: October 27, 2017, 07:50:01 AM »
you have the following embed code;

  p_web.Script('getLocation()')
  p_web.SSV('LOC:Latitude',p_web.GSV('_Latitude_'))
  p_web.SSV('LOC:longitude',p_web.GSV('_Longitude_'))

the problem is that you're thinking very synchronously here.

the first line;
  p_web.Script('getLocation()')
is an instruction to the browser to run a Javascript function called getLocation.
I'll only _send_ this script when the request completes, so the next 2 lines are useless here.

hence the need to press the button multiple times...

cheers
Bruce