I'm working in order to connect my client to my server (node.js). I use this code :
var storeEmployees = new qx.data.store.Json("Load/Infos");
qx.event.Registration.addListener(storeEmployees, "loaded", function(){
var model = this.getModel();
console.log(model.getRecords());
console.log(model.getTotal());
console.log(model.getStatus());
}, storeEmployees);
My server send this value :
{records: ["bonjour", "aurevoir"], total:2, status:"success"}
however the "console.log(model.getRecords())" write on the console :
Object[undefined, undefined]
Instead of
Object["bonjour","aurevoir"]
Values for "getTotal" and "getStatus" are good. The problem is only for the array (simple array and complexe array).
Any idea ?
Thanks in advance !
The store marshals the data to model objects. This means that you are dealing with qx.data.Array here which unfortunately can not be accessed vie brackets notation (e.g. Data[0]). But this is what the console does. For debugging and logging you can access the plain array with the .toArray() method which then will show the results.
Related
I extracted from a previous response an Object of tuple with the following regex :
.check(regex(""""idSc":(.{1,8}),"pasTemps":."codePasTemps":(.),"""").ofType[(String,String)].findAll.saveAs ("OBJECTS1"))
So I get my object :
OBJECTS1 -> List((1657751,2), (1658105,2), (4557378,2), (1657750,1), (916,1), (917,2), (1658068,1), (1658069,2), (4557379,2), (1658082,1), (4557367,1), (4557368,1), (1660865,2), (1660866,2), (1658122,1), (921,1), (922,2), (923,2), (1660875,1), (1660876,2), (1660877,2), (1658300,1), (1658301,1), (1658302,1), (1658309,1), (1658310,1), (2996562,1), (4638455,1))
After that I did a Foreach and need to extract every couple to add them in next requests So we tried :
.foreach("${OBJECTS1}", "couple") {
exec(http("request_foreach47"
.get("/ctr/web/api/seriegraph/bydates/${couple(0)}/${couple(1)}/1552863600000/1554191743799")
.headers(headers_27))
}
But I get the message : named 'couple' does not support index access
I also though that to use 2 regex on the couple to extract both part could work but I haven't found any way to use a regex on a session variable. (Even if its not needed for this case but possible im really interessed to learn how as it could be usefull)
If would be really thankfull if you could provided me help. (Im using Gatling 2 but can,'t use a more recent version as its for work and others scripts have been develloped with Gatling2)
each "couple" is a scala tuple which can't be indexed into like a collection. Fortunately the gatling EL has a function that handles tuples.
so instead of
.get("/ctr/web/api/seriegraph/bydates/${couple(0)}/${couple(1)}/1552863600000/1554191743799")
you can use
.get("/ctr/web/api/seriegraph/bydates/${couple._1}/${couple._2}/1552863600000/1554191743799")
I am trying to merge two jsons into one but can't make it work. I manage to retrieve the data I need from both get, but I have troubles manipulating the jsons.
I planned on using two for loops but it doesn't work :
$scope.coursesJson = $http.get('https://api.myjson.com/bins/18zi3');
$scope.reviewsJson = $http.get('https://api.myjson.com/bins/52toz');
$q.all([$scope.coursesJson, $scope.reviewsJson]).then(function (values){
$scope.coursesJson = values[0];
$scope.reviewsJson = values[1];
for(i = 0;i<$scope.coursesJson.length;i++){
for(j = 0;j<$scope.reviewsJson.length;j++){
if($scope.coursesJson[i].name = $scope.reviewsJson[j].name){
$scope.coursesJson[i].reviews.push($scope.reviewsJson[j]);
}
}
}
console.log($scope.coursesJson);
});
Using the console, I can visualise the data but $scope.coursesJson.length is undefined and I don't understand why.
Maybe I don't understand $q well ?
EDIT :
Here is an example of the elements you could find in the coursesJson file I get() :
[{"code":"123 ","name":"Acteurs","courseContentGrade":null,"courseTeachingGrade":null,"courseAverage":null,"reviews":null},
{"code":"1234","name":"Advanced Excel","courseContentGrade":null,"courseTeachingGrade":null,"courseAverage":null,"reviews":null}]
And an example of the elements you could find in the reviewsJson file I get() :
[{"code":"123 ","name":"Acteurs","professor":"Lalala","contentReview":"C'est très réussi.","teachingReview":"charismatique","contentGrade":8,"teachingGrade":8,"average":8,"trimester":"T2","day":"Jeudi / Thursday","time":"9h-12h","round":"1er tour","bet":21,"year":"2014/2015","upvotes":"0","author":"Piranha","passed":null},
{"code":"123 ","name":"Acteurs","professor":"LAlalalala","contentReview":"Très intéressant !","teachingReview":"Disponible, claire.","contentGrade":8,"teachingGrade":8,"average":8,"trimester":"T2","day":"Jeudi / Thursday","time":"9h-12h","round":"1er tour","bet":25,"year":"2014/2015","upvotes":"0","author":"Piranha","passed":null}]
I would like to add the elements found in the reviewsJson to the reviews field of the elements of coursesJson. Could that be the problem ? I thought that using the push() method would create the array, but maybe I need to change all "reviews":null to "reviews":[] in coursesJson ?
I went to the url https://api.myjson.com/bins/ID1 and it's not an array, but an object. Instead of $scope.coursesJson.length I think you shouldbe doing $scope.coursesJson.tracks.length
I solved my issue really easyly and my question was actually pretty stupid.
What I tried to achieve didn't have its place on the front but on the backend.
Okay, I've been bashing my head bloody on this one:
I have the following JSON coming back from the server:
{
"SendDate" : "2015-03-16T22:48:27.747",
"SendTo" : {
"ContactIds" : ["28a24538-cdfc-4453-920d-86f57d7eaf22"],
"GroupIds" : []
},
"Message" : "MEETING TIME!!!!!"
}
I have checked this with several REST clients - this IS what comes back.
I have AngularJS "getting" this with an $http.get() operation, but I get an undefined on the "ContactIds" value - so, what I see in the JS Console is:
SendDate : "2015-03-16T22:48:27.747"
SendTo:
ContactIds: Array[1]
0: undefined
length: 1
I have NO IDEA what can be causing this.
Any ideas?
UPDATE:
I have attached an interceptor and intercepted the response and the result is the same when I feed the data to the console - but when I use:
JSON.stringify(data)
I can see that the Data in the Array is THERE!
UPDATE 2:
Okay now this is driving me nuts. I have played with the interceptor and if I stringify the response and then use JSON.parse() - it works fine, but when I pass the response through, it comes out messed up again.
I traced it through angular's parsing process all the way to the "fromJson()" function. (code below:) It comes into the function as a string. (Now here's the Bizzarro part)
I altered the code like this:
function fromJson(json) {
var obj1 = JSON.parse(json);
console.log("Obj1:");
console.log(obj1);
//my altered angular code
var obj2 = isString(json) ? JSON.parse(json) : json;
console.log("Obj2:");
console.log(obj2);
// Pass to program...
return obj1;
//return obj2;
/* original angular code:
return isString(json)
? JSON.parse(json)
: json;
*/
}
If I run it and return obj1, the console logs obj1's ContactIds "0" index as "undefined" - but obj2 logs as "28a24538-cdfc-4453-920d-86f57d7eaf22".
"GREAT!", I'm thinking - so I return obj2, but now it logs undefined but obj1's "0" index is now the correct value. (WTH?)
So I reverse the code, just to see, and Return obj1 - and I'll be damned - obj2 returns "28a24538-cdfc-4453-920d-86f57d7eaf22" and obj1 is undefined. (It's like teasing a monkey.)
It HAS to be something later on in the pipeline that is doing it - OR - it may have something to do with the array being GUID strings - but I use GUID strings elsewhere with no problems.
It could also be another "angular process" that I'm unaware of that is causing this - angular is quite impressive.
Either way, I'm super-confused.
This is so stupid - I'm surprised that an array of strings is such a difficulty - and what's worse, it seems I'm the only one having this problem. (I researched this for six hours yesterday...)
Any other ideas, guys?
OH MY GOD I'M SO STUPID!!!
First I'd like to thank everyone for trying to help me.
The answer is this - there was no problem, that is, not with Angular or its parser.
The Problem is that the Console was logging transformed data, which had an error at MY controller. The data on MY end was not matching the data in the list that I had in my controller - (Database Error).
BOTTOM LINE:
If you have this error pop up, do NOT troubleshoot from the top-down - troubleshoot from the bottom-up.
Angular has many checks and balances - if you don't get "bleeding failures" throughout the program, chances are the error is in YOUR code.
Thank you everyone for your help.
I want to transfer a file from a form to a webworker. In chrome i simple can use this code to transfer a FileList-Object:
worker.postMessage(files: array_files);
But with Firefox i get this error:
Transfer file to webworker: DataCloneError: The object could not be cloned.
So i tried to use the Syntax for transferable objects. Something like this?
var post = {files: array_files, file_ids: response.file_ids};
worker.postMessage(post, [post]);
But with that i get this in Chrome
Uncaught DataCloneError: Failed to execute 'postMessage' on 'Worker': Value at index 0 does not have a transferable type.
And still
DataCloneError: The object could not be cloned.
in Firefox.
What is the right way to pass a FileList to a worker?
I don't know how to pass File objects with postMessage, but at the least I can advise that transferable objects do not work in this way. The optional second parameter is an array of the backing ArrayBuffer instances of any typed arrays you wish to pass. So for instance, suppose the message you would like to post is a structured object:
var message = {foo: 'abc', bar: new Uint8Array(...)};
worker.postMessage(message, [message.bar.buffer])
Also notice that passing a typed array to another worker/window as a transferable object makes the transferred array inaccessible from the sending worker/window.
I've imported several images into an actionScript 3 document. I've turned them all into symbols (movie clips) and given them instance names to reference from ActionScript.
Ok, so I'm putting the instances into an array so I can loop through them easily, but for some reason, whenever I'm putting in the instance name, I do a trace on the value in the array and it's giving me the symbol object back, rather than the instance object.
Basically trying to loop through the array to make each instance's visibility = false
Here's a sample:
var large_cap_extrusion_data: Array = new Array();
large_cap_extrusion_data[0] = large_cap_extrusion_menu_button;
large_cap_extrusion_data[1] = extrusion_border_large_cap
large_cap_extrusion_data[2] = "Large Cap";
large_cap_extrusion_data[3] = large_cap_main_menu_button;
var extrusion_data: Array = new Array();
extrusion_data[0] = large_cap_extrusion_data;
trace(extrusion_data[0][0]);
The traces gives:
[object large_cap_menu_button]
(the parent symbol)
rather than:
"large_cap_extrusion_menu_button"
I'd be very grateful if someone could tell me where I'm going wrong...
when you trace and object, by default it describes it type. What you want is the "name" property of the object.
Try this:
trace(extrusion_data[0][0].name);
that should give you the instance nema of the large_cap_menu_button rather than the class description. Either way, you have the right object I bet.