#1 2016-04-01 08:03:37

tin
Member
Registered: 2016-03-20
Posts: 173

Cannot get value with ObjectGetProp after update from 2016.95

Hi, David
I meet some issue after update from 2016.95

2016.95 (03/31/2016)
* Fix a bug in the ObjectGetProp action which causes we can't get the expected object's property value if we try to use a variable for the object's property name. Thanks Terje!

This is my code from login view.Before I update it can get data.I use HttpClient Post method to get data array from mysql via php in json format.It response normally.

//split response array to string from 0 to 0
    ArrayGetItem "[loginclient.Response]" "0" "[loginItem]"
// Get each string password
    ObjectGetProp "[loginItem]" "usrp" "[usrp]"
    ObjectGetProp "[loginItem]" "roleusr" "[roleusr]"

loginclient.Response = Httpclient can get data from json
ObjectGetProp cannot get my data out from array after I update to 2016.95

Do I miss something?

Offline

#2 2016-04-01 08:37:49

tin
Member
Registered: 2016-03-20
Posts: 173

Re: Cannot get value with ObjectGetProp after update from 2016.95

Here,in console I rollback to 2016.94 and capture
v. 2016.94
281sn7c.png

v. 2016.95 update at 04/01/2016 (It 2016.96 in description but in program still 2016.95)
24cyslh.jpg

in older version can get data.

Offline

#3 2016-04-01 08:39:53

tin
Member
Registered: 2016-03-20
Posts: 173

Re: Cannot get value with ObjectGetProp after update from 2016.95

I rollback for now.
I investigating...found error at sample json2
because json2 sample is the same code with my code
It cannot get value too

in console error

--------------------------------------------------------------------------------

App Builder saved debugger console
App name: JSON2
Generated: 4/1/2016 2:10:41 PM

--------------------------------------------------------------------------------

Legend:

[a] App action
[n] Net request
[i] Information message
[w] Warning message
[e] Error message
[u] Unknow message
[+] Block start
[-] Block end

--------------------------------------------------------------------------------


[n] Resolved "D:\Users\Administrator\Documents\AppBuilder\Samples\JSON2\JSON2_Compiled\www\index.html"
[n] Resolved "D:\Users\Administrator\Documents\AppBuilder\Samples\JSON2\JSON2_Compiled\www\builder\styles\default.css"
[n] Resolved "D:\Users\Administrator\Documents\AppBuilder\Samples\JSON2\JSON2_Compiled\www\builder\styles\builder.css"
[n] Resolved "D:\Users\Administrator\Documents\AppBuilder\Samples\JSON2\JSON2_Compiled\www\app\styles\scaled.css"
[n] Resolved "D:\Users\Administrator\Documents\AppBuilder\Samples\JSON2\JSON2_Compiled\www\app\scripts\app.js"
[n] Resolved "D:\Users\Administrator\Documents\AppBuilder\Samples\JSON2\JSON2_Compiled\www\builder\scripts\builder.js"
[n] Resolved "D:\Users\Administrator\Documents\AppBuilder\Samples\JSON2\JSON2_Compiled\www\cordova.js"
[n] Resolved "D:\Users\Administrator\Documents\AppBuilder\Samples\JSON2\JSON2_Compiled\www\builder\fonts\digital-7-mono.ttf"
[n] Resolved "D:\Users\Administrator\Documents\AppBuilder\Samples\JSON2\JSON2_Compiled\www\app\views\NewView1.html"

[+] Start of Button1 Click event
[a] 000001 HttpExecute "HttpClient"
[-] End of Button1 Click event

[n] Resolved "D:\Users\Administrator\Documents\AppBuilder\Samples\JSON2\JSON2_Compiled\www\app\files\data.json"

[+] Start of HttpClient Success event
[a] 000001 SetVar "[Textarea.Value]" "" "String"
[a] 000002 ArrayLength "[HttpClient.Response]" "[TotalRecords]"
[a] 000003 Dec "[TotalRecords]"
[a] 000004 Loop "0" "[TotalRecords]" "[I]"
[a] 000005 SetVar "[SportsLog]" "" "String"
[a] 000006 ArrayGetItem "[HttpClient.Response]" "[I]" "[Item]"
[a] 000007 ObjectGetProp "[Item]" "ID" "[ID]"
[a] 000008 ObjectGetProp "[Item]" "Name" "[Name]"
[a] 000009 ObjectGetProp "[Item]" "Sports" "[Sports]"
[a] 000010 ArrayLength "[Sports]" "[TotalSports]"
[e] Error: "Unable to get property 'length' of undefined or null reference" - Line: 290 - Char: 13 - Code: 0 - Url: http://127.0.0.1:9999/app/scripts/app.js

--------------------------------------------------------------------------------

©2016 David Esperalta's App Builder

More information at http://www.davidesperalta.com/

--------------------------------------------------------------------------------

Last edited by tin (2016-04-01 09:11:55)

Offline

#4 2016-04-01 09:42:45

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,709
Website

Re: Cannot get value with ObjectGetProp after update from 2016.95

Hello,

First of all, sorry for the inconveniences. And thanks for your feedback and research tin. Yesterday I fix a bug in the "ObjectGetProp" action, and, now they works as expected, however, we can't write something like this code now:

ObjectGetProp "[loginItem]" "usrp" "[usrp]"
ObjectGetProp "[loginItem]" "roleusr" "[roleusr]"

This simple "confuse" the App Builder code translator. What we must to do is something like the below one:

ObjectGetProp "[loginItem]" "usrp" "[ItemUsrp]"
ObjectGetProp "[loginItem]" "roleusr" "[ItemRoleusr]"

That is, the property name must be different to the result variable. So remember the below code doesn't work:

NewObject "[MyObject]"

ObjectSetProp "[MyObject]" "PropName" "My value"
ObjectGetProp "[MyObject]" "PropName" "[PropName]"

AlertBox "[PropName]" "info"

But this other works like expected:

NewObject "[MyObject]"

ObjectSetProp "[MyObject]" "PropName" "My value"
ObjectGetProp "[MyObject]" "PropName" "[PropValue]"

AlertBox "[PropValue]" "info"

I want to study this deeply, but this behaviour is not only related with this specific action, then, take note tin.

Offline

#5 2016-04-01 09:56:21

tin
Member
Registered: 2016-03-20
Posts: 173

Re: Cannot get value with ObjectGetProp after update from 2016.95

I understood it thanks,David.It better to use other name that was not the same key name(it make me confuse too.But I copy your sample code from json2 sample hahaha)

Ps.You need to change code in json2 sample too.It will make newer confuse too.

thanks for quick support. David smile

Offline

#6 2016-04-01 09:58:09

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,709
Website

Re: Cannot get value with ObjectGetProp after update from 2016.95

Hello tin,

Thanks for your considerations. The JSON2 sample has been fixed and AB is now updated. Certainly I need to study this kind of situation, because maybe I can take another approach, which allow us to name variables like object properties, etc.

Offline

#7 2016-04-01 10:06:38

tin
Member
Registered: 2016-03-20
Posts: 173

Re: Cannot get value with ObjectGetProp after update from 2016.95

It better to be not the same name ,David.
(I don't know that can set not the same,that why I coding like that. lol

Offline

#8 2016-04-01 10:09:47

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,709
Website

Re: Cannot get value with ObjectGetProp after update from 2016.95

Hello,

tin wrote:

It better to be not the same name ,David.
(I don't know that can set not the same,that why I coding like that. lol

Probably the better can be to allow us to choose: use the same name or not to use it. smile

Offline

#9 2016-04-01 14:51:10

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,709
Website

Re: Cannot get value with ObjectGetProp after update from 2016.95

Hello,

David wrote:

Probably the better can be to allow us to choose: use the same name or not to use it. smile

I made the appropiate changes in order to allow us to write code like this without problems:

NewObject "[MyObject]"

ObjectSetProp "[MyObject]" "PropName" "My value"
ObjectGetProp "[MyObject]" "PropName" "[PropName]"

AlertBox "[PropName]" "info"

Changes also affects to some other actions in the same way than the "ObjectGetProp" action.

Offline

#10 2016-04-01 21:51:38

tin
Member
Registered: 2016-03-20
Posts: 173

Re: Cannot get value with ObjectGetProp after update from 2016.95

Thanks!!

Offline

#11 2016-04-01 23:20:01

David
Admin
From: Alcobendas, Madrid, Spain
Registered: 2015-04-21
Posts: 1,709
Website

Re: Cannot get value with ObjectGetProp after update from 2016.95

Hello,

tin wrote:

Thanks!!

You're welcome!

Offline

Board footer

Powered by FluxBB


Copyright ©2018 DecSoft. All rights reserved.