Opened 7 years ago

Closed 7 years ago

#14894 closed defect (invalid)

JsonRest, Observable, Cache and MemoryStore not notifying Tree

Reported by: omega Owned by: omega
Priority: undecided Milestone: tbd
Component: Data Version: 1.7.2
Keywords: Cc:
Blocked By: Blocking:

Description (last modified by bill)

I have a new-style JsonRest object store which I'm trying to use to populate a Tree.

The initial query and setup of the Tree works great. However after a successful put() on my "model" does not trigger any kind of update to the Tree.

This is in spite of attempting the following configurations:

o JsonRest wrapped in Observable
o JsonRest and MemoryStore? wrapped in a Cache
o JsonRest and MemoryStore? wrapped in a Cache, wrapped in an Observable.
o MemoryStore, wrapped with Observable - with a JsonRest, both wrapped with a Cache.
o MemoryStore, wrapped with Observable - with a JsonRest, both wrapped with a Cache, all wrapped with Observable.

In many of these configurations, the Tree continued to populate with data, it just never reflected new records being added.

I suspect there's a chance that this is simply a documentation issue - but I find it to be a glaring one as I'm currently still left with questions:

o What is the proper way to bind a Tree to a JsonRest?
o What should my server be returning to satisfy Dojo? I assume an ID, but how? As the entire created object, or just the ID? In an array?
o How could I have trouble-shot this issue myself?

As always, thanks for all the hard work!

Attachments (1)

test.tar.gz (1.6 KB) - added by omega 7 years ago.
Example.

Download all attachments as: .zip

Change History (12)

comment:1 Changed 7 years ago by bill

Component: GeneralData
Description: modified (diff)
Owner: set to Kris Zyp

You'll need to attach a test case to this and any bug you file, thanks.

See dijit/tests/tree/Tree_with_JRS.html for an example of a server-less test, although that's running against dojox.data.JsonRestStore instead of dojo.data.JsonRest. I'll upgrade it at some point.

Last edited 7 years ago by bill (previous) (diff)

comment:2 Changed 7 years ago by bill

Owner: changed from Kris Zyp to omega
Status: newpending

comment:3 Changed 7 years ago by omega

Status: pendingnew

Hopefully this is enough to go off of:

https://github.com/atrauzzi/Nerve/blob/master/web/praxis/js/lib/omegatech/praxis/Controller.js

Line #310 is where I initialize the JsonRest?. Lines #371 to #384 are some attempts of mine to hook everything up.

At a glance it should be clear what it is I'm doing wrong or if there is in fact missing functionality.

Thanks!

comment:4 Changed 7 years ago by omega

(those numbers are obviously not tickets, sorry!)

comment:5 Changed 7 years ago by bill

Status: newpending

Actually, that's neither an attachment nor a test case, you need to use the "attach file" button to give something where we can reproduce the problem.

comment:6 Changed 7 years ago by omega

Status: pendingnew

Are you sure that's necessary despite me offering a link to the exact code? This is a somewhat complex scenario involving AMD, a controller class and the rest of my application. What I've seen so far with the code I've linked in is that I can get the initial root-level listing of tree elements and successfully conduct updates. It's having the Tree reflect the new data that's an issue.

Perhaps it's event related?

Really all that's necessary is to:

o Set up a JsonRest?

o Hook it up to a Tree

o Succesfully create a new object via the JsonRest?

o The Tree does not update itself.

This also happens when you use MemoryStore? and Observable in the mix as well. I'd be more than happy to answer followup questions from the developer(s) to give specific details.

comment:7 Changed 7 years ago by bill

Well, I'm definitely not going to look at it without a runnable minimal test case. You can see if Kris responds.

Changed 7 years ago by omega

Attachment: test.tar.gz added

Example.

comment:8 Changed 7 years ago by omega

Okay, I've attached an "example", although you'll be better served by seeing my referenced github code. Especially, without a server. It's difficult to make the case effectively.

As I mentioned earlier, I'm more than happy to answer any questions and help go through it all. I think that'll ultimately prove to be more useful.

comment:9 Changed 7 years ago by bill

Description: modified (diff)

OK, I looked at the test case, but it won't run for me without setting up my server to take PUT requests.

I did look at your client-side code a bit, and it seems like you are missing a bunch of code. This is what dijit/tree/ObjectStoreModel was written for. I suggest you use it to connect the store to the Tree, rather than trying to hand-wire it. At the least, look at the ObjectStoreModel code to see how it calls onChange() and onChildrenChange() based on notifications from Observable.

Hopefully that will solve all your issues, but not sure.

Last edited 7 years ago by bill (previous) (diff)

comment:10 Changed 7 years ago by omega

Perfect, thanks for your help. That definitely clears it up. Perhaps some notes in the documentation and tutorials drawing more attention to ObjectStoreModel? would be in order?

I wasn't quite aware that it existed and what role it fulfilled. Further help from kgf on IRC helped me understand that I was simply implementing a lot of the "missing" methods in my JsonRest? as per one tutorial on the Dojo site.

Thanks!

comment:11 Changed 7 years ago by bill

Resolution: invalid
Status: newclosed

OK, glad you got it working.

The examples in http://livedocs.dojotoolkit.org/dijit/Tree all reference ObjectStoreModel, but I can still see some references in the text about the old TreeStoreModel/ForestStoreModel, so I'll update those. Plus add a page for ObjectStoreModel itself pointing back to the Tree page.

Note: See TracTickets for help on using tickets.