PDA

View Full Version : Creating a model Instance with json data?



börn
27 Jan 2012, 1:50 AM
Hi there... or whattheheck? ;)

Is there a reason why the constructor of Model (with a given data object as parameter) behaves differently as model.load()?

I thought i could use the constructor to instantiate my model instance with a data object already sent to the client (before) and load this record to my form.
At first everything looked good, but then i declared a mapping in one of my fields and i was wondering why this didn't work at all... then I stepped through the code and I had to notice, that the constructor didn't seem to work with the configured reader, so the fine mapping-extractor-functions built before, didn't get involved... why?? ;)

so I have to reload my data with model.load after the site has been sent to the browser because load works with the configured reader and makes everything good...

Is that right? So why do we have this constructor, if we aren't able to use this in a correct way? Or if it's used internally, please document that properly in the api and that one might use another way ;)

TIA
börn