Getting 'too much recursion' error when trying to serialize Qooxdoo-Object - qooxdoo

I tried to serialize my qooxdoo-object to JSON but I always get a 'too much recursion'-errormessage (in Firebug-console) if I try the following:
qx.util.Serializer.toJson(this.getGameData())
Also .toNativeObject-function throws this error. The API-manual is very thin for this: http://www.qooxdoo.org/current/apiviewer/#qx.util.Serializer
Does anybody have a working example for me or a suggestion what could be the reason for this?
Thank you and greetings

One of your objects must have a property or similar which refers to an object which has already been serialised - there's nothing wrong with using qx.util.Serializer, but if you give it an object which has recursive references you will get a recursion error.
You can use the Qooxdoo Playground (http://www.qooxdoo.org/devel/playground/) to create an example of your problem so that others can help diagnose you problem; when you can reproduce it, use the "Shorten URL" button to create a tinyurl link.
Here's a working example of qx.util.Serializer, you can copy & paste it into the playground (SO wont let me use tinyurls :( )
qx.Class.define("abc.MyClass", {
extend: qx.core.Object,
properties: {
alpha: {
init: null,
nullable: true
}
}
});
var my = new abc.MyClass();
my.set({ alpha: 1 });
this.debug(qx.util.Serializer.toJson(my));
/* ******************************
* Show the log by clicking the "Log" button in the toolbar to see the output
*/

Related

Deleting item from Array once handled by a List in SwiftUI

I'm convinced I'm overthinking this and ending up in a loop of not being able to solve this issue. The short of it is I have an array which includes dates which I am displaying in a list in my main view. The entries will fire notifications to users based on the time of the date.
I want to be able to remove entries from the Array or View where the date is older than the current date and only show users the up to date entries. Almost everything I've found online doesn't seem to apply to this and I'm going round in circles trying to resolve this.
Theres a lot to unpack with my code so I've condensed it down.
struct EventListView: View {
var body: some View {
NavigationView {
//Loads the array from a CSV - no issues with this, been working with it for
all other functions in the app.
var events = loadCSV(from: "Eventtest")
List(events, id: \.id) { event in
//This function returns a true/false bool which I want to use to remove
from view/array
let eventinpast = dateInPast(value: event.date)
HStack{
VStack(alignment: .leading, spacing: 5){
Text(event.name)
.font(.subheadline)
.foregroundColor(.secondary)
Text(event.event) //confusing but this is correct.
.font(.subheadline)
.foregroundColor(.secondary)
Text(event.date)
Text(event.time)
}.frame(width: 200.0, alignment: .topLeading)
}
}
}
}
}
I've tried to change the List to include a "ForEach" but this doesn't resolve the issue as everything I've found online for this revolves around a user action to delete/remove, but I want the bool to decide if the event item is displayed/deleted or not.
I've removed my attempts for trying to delete/remove items because at this point I'm tripping myself up constantly and I'm not convinced I'm looking at the problem from the right perspective.
Most recent attempt has been following this: https://www.hackingwithswift.com/books/ios-swiftui/building-a-list-we-can-delete-from
But instead of using .onDelete I tried .onAppear but no deals. Sorry if proposing this problem is rambling, I'm quite drained from trying to get what I thought would be really simple functionality working.
Any help would be greatly appreciated! Thank you.
Sometimes it is better to do the model stuff first.
var events = loadCSV(from: "Eventtest")
events = events.filter() { !dateInPast(value: $0.date) }
how about SHOWING only the relevant events:
var events = loadCSV(from: "Eventtest").filter { !dateInPast(value: $0.date) }
or
List(events.filter { !dateInPast(value: $0.date) }, id: \.id) { event in
Thanks so much #dtm & #ChrisR!
I knew I was overthinking what I was trying to do. I've ended up with this.
var events = loadCSV(from: "Eventtest")
var events = events.filter { !dateInPast(value: $0.date) }
There are some other date eval's in scope for the view but that can be moved into the loadCSV function or dateInPast, tidies it up a bit too. Unfortunately I can't upvote since my account is new. Thanks so much though. Cheers!

Angular Request how it works for nestjsx/crud

I've been trying for hours to make it work and I can't do it, I hope some of you have the answer to my question because it must be very simple and I am a beginner
I am using AngularJs and NestJs in Nest used the #nestjsx/crud and I went trow the request docs so, here is the problem:
This is my Angular service function
getProductsOfPiece(pieceId: number): Observable<ProductSimple[]> {
return this.http.get<ProductSimple[]>(
'api/producto/', {
params: {
fields: "id,refFabr,refCliente,descrCorta,imagen",
filter: 'pieza.id||$eq||'+ pieceId
}
}
);
}
This request gives me a 400 Bad Request, it looks like this:
/api/producto/?fields=id,refFabr,refCliente,descrCorta,imagen&filter=pieza.id%257C%257C$eq%257C%257C1
I imagine the % and the hexadecimal have something to do with the URI coding and tried to encode/decode it, but didn't work.
I also tried using the class RequestQueryBuilder of #nestjsx/crud-request from the FrontEnd usage referenced in the docs, and append it to the URL
let queryString = RequestQueryBuilder.create()
.select(["id","refFabr","refCliente","descrCorta","imagen"])
.setFilter({
field: "coleccion.id",
operator: CondOperator.EQUALS,
value: collectionId
}).query();
return this.http.get<ProductSimple[]>(
'api/producto/?'+queryString
);
but got worse result
/api/producto/?fields=id%2CrefFabr%2CrefCliente%2CdescrCorta%2Cimagen&filter%5B0%5D=pieza.id%7C%7C%24eq%7C%7C1
What I don't understand is how I do this with my Postmand and it works!
api/producto/?fields=id,refFabr,refCliente,descrCorta,imagen&filter=coleccion.id||$eq||6
How can I make it work, what is wrong with my code?
Finally got the answer, just had to set the .query(false) on the RequestQueryBuilder, this boolean parameter is for encode, seams like Angular's HttpClient class does some encoding or something to the URL so, anyway
It Works! Here is the code:
getProductsOfPiece(pieceId: number): Observable<ProductSimple[]> {
let queryString = RequestQueryBuilder.create()
.select(["id","refFabr","refCliente","descrCorta","imagen"])
.setFilter({
field: "coleccion.id",
operator: CondOperator.EQUALS,
value: collectionId
}).query(false);
return this.http.get<ProductSimple[]>(
'api/producto/?'+queryString
);
}
And you need to import
RequestQueryBuilder of #nestjsx/crud-request
npm i #nestjsx/crud-request.
Any observations are welcome...
UPDATE
To create or update
Here are de docs
Create One https://github.com/nestjsx/crud/wiki/Controllers#create-one-resource
Update One https://github.com/nestjsx/crud/wiki/Controllers#update-one-resource
Following that guide the create and update are simple
Just do POST to the API 'api/producto/' (for example) with the object as body in the request
For the Update follows similar just using the PUT method and the API with the model id 'api/producto/1' (for example)

Strange jump on map after click

I have a strange problem with Here maps (JS).
After catching a click event on another element in the page (ex: custom bubble or search field) the map starts to flick like in the gif below
Example : https://i.imgur.com/kKrtwMj.gif
Any idea?
Thanks
I found a temporary solution.
It consist of re-instantiate the H.mapevents.MapEvents object and the H.mapevents.Behavior at the time the bug occurs.
mapEvents.dispose();
mapEvents = new H.mapevents.MapEvents(map);
behavior = new H.mapevents.Behavior(mapEvents, { kinetics: { duration: 3, power: 1 } });

Laravel 4 not getting JSON from input Backbone.js

I have read and worked with the other posts about this and it appears the version of Laravel 4 I just downloaded has more changes made to the way the JSON input is handled by a controller.
$input = Input::json()->all(); gives me errors as if I am referring to something that does not exist when I request some part of the payload after doing a PUT request. And without ->all(); I get a symfony error.
Does anyone know how to get good JSON from backbone in Laravel 4's latest version?
Currently, I am doing the long way around to get my data, ie:
$input_title = Input::get('title');
$input_completed = Input::get('completed');
$task = Task::find($id);
$task->title = $input_title;
$task->completed = $input_completed;
$task->save();
Yes, I am doing the tutorial on tutsplus to learn laravel/backbone, so a little noob patience is apreciated.
The error I get when using Input::get(); is:
{"error":{"type":"UnexpectedValueException","message":"The Response content must be a string or object implementing __toString(), \"array\" given.","file":"/Users/brentlawson23/Sites/laravel4App/bootstrap/compiled.php","line":16858}}
I really want to get the Laravel-specific answer instead of using straight php to stringify the payload.
I get same error using just Input::json();
For the current beta of Laravel 4, Input::json(); is not getting a stringified version of the request payload that can be used to create a new row in a table, nor does Input::json()->all(); (hoping to play nice with the ParameterBag from symfony). I have tried json_encode among other hacks and basically every step of the way in this tut, I hit some brick wall. Anyone have a suggestion based on what I have presented here?
Today I got this when simply trying to echo the result of $input = Input::json(); :
{"error":{"type":"ErrorException","message":"Catchable Fatal Error: Object of class Symfony\Component\HttpFoundation\ParameterBag could not be converted to string in /Users/brentlawson23/Sites/laravel4App/app/controllers/TasksController.php line 45","file":"/Users/brentlawson23/Sites/laravel4App/app/controllers/TasksController.php","line":45}}
Yes, I have studied the Symfony API.
I had a similar problem. Input from Backbone is converted to array in Laravel. On tutsplus, Jeffrey Way is using object. So I was trying to do this (like in tutorial):
return $input->title // using object,but got an error.
If I change that line to:
return $input["title"] // everything works fine with array.
I'm also working through the Backbone tutorial on tuts+. If I'm right in assuming are you stuck on the Creating New Contacts section? Below is how I got it to work for me, in ContactController.php:
public function store()
{
$input = Input::all();
Contact::create(array(
'first_name' => $input['first_name'],
'last_name' => $input['last_name'],
'email_address' => $input['email_address'],
'description' => $input['description']
));
}
And then also needed to update app/models/Contact.php with the below:
class Contact extends Eloquent {
protected $fillable = array('first_name', 'last_name', 'email_address', 'description');
}
That should get it working for you and insert the contact into the database. If I've misread let me know and I can have another look.
Cheers,
Sean

qx.ui.form.Spinner.setValue() question

I got a qx.ui.form.Spinner object and I am setting the initial value from an XML file. The value is unfortunately returned as a string, which leads to the following confusing error in Firebug:
Error in property value of class qx.ui.form.Spinner in method setValue with incoming value '3': Is invalid!
Running this sample in the Playground doesn't produce any error, but the spinner is not being set:
// Create a button
var button1 = new qx.ui.form.Button("First Button", "icon/22/apps/internet-web-browser.png");
// Document is the application root
var doc = this.getRoot();
var spinner = new qx.ui.form.Spinner(1, 1, 60);
doc.add(spinner);
// Add button to document at fixed coordinates
doc.add(button1,
{
left : 100,
top : 50
});
// Add an event listener
button1.addListener("execute", function(e) {
spinner.setValue("3");
});
So my questions are:
should the string value be working? So far it seemed to be seldom a problem when number are actually string.
should the Playground give an error?
To answer your questions:
No, the string value will not work. Try using the parseInt() function to convert the string into an integer.
Actually the Playground is giving a problem, but the exception is not handled by the Playground, Try adding a try .. catch and you will see the exact same errormessage you already know.
try {
spinner.setValue("3");
} catch (e) {
alert(e);
}
Thanks.
I already uses parseInt() to get it worked and I submitted a bug report: http://bugzilla.qooxdoo.org/show_bug.cgi?id=4457
I daresay the Playground should at least log the error in its "Log" window. You might want to consider opening a bug for this.

Resources