0

Syncing Trees Across Desktops

asked 2009-12-07 11:46:46 +0800

mpassell gravatar image mpassell
54 3
http://blog.grovehillsoft...

I'm having trouble implementing something in ZK and thought I'd ask if anyone out there has any suggestions. I'm creating a UI to display and work with a hierarchical data structure within an app already using ZK 3.6.2. Not surprisingly, I went with a ZK Tree backed by a TreeModel - essentially a thin wrapper on top of the hierarchical data. Everything works great for a single user, but problems arose when it turned out that the data structure needed to be accessible to multiple users at the same time.

There will be complexity associated with keeping the data structure thread-safe, but I'm okay with that. The part I'm less sure about is how to keep the visible Trees in sync across multiple desktops. My first thought was to use a singleton TreeModel, maintaining an association between Desktops and their listeners, and then activating the desktops when it was time to fire TreeDataEvents to listeners on other desktops. That didn't work. If you know the ZK event code (better than I do), you'll know that activating desktops is only possible when listener methods are being invoked. Given that the trees are themselves the listeners, I can't easily have them activate their associated desktop when responding to events. I had some thoughts about other approaches, but they all seemed pretty complicated. Any suggestions? (I don't think we'll be moving to ZK 5 in this release of the product, so although I'd be interested to hear about ZK 5 solutions, what I need for now is something that will work with 3.6.x)

Thanks,
Matt

delete flag offensive retag edit

5 Replies

Sort by ยป oldest newest

answered 2009-12-11 04:03:36 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

You can take a look at the smalltalk of server push.

link publish delete flag offensive edit

answered 2009-12-16 10:41:19 +0800

mpassell gravatar image mpassell
54 3
http://blog.grovehillsoft...

Hi Jumper,

Thanks. I'd already seen that.

If anyone's curious, I ended up taking the following approach. Every user/Desktop gets its own TreeModel. That TreeModel is then registered as a listener using our app's own event tracking mechanism. Whenever changes are made to the underlying hierarchical data, an event is fired to all listening TreeModels (activating and deactivating Desktops as necessary). Those TreeModels then translate the event into an appropriate ZK TreeDataEvent and refire them.

It's not perfect, but it works. When we move to ZK 5, we'll take a look at whether some of our event tracking could be handled by the application-scoped event queues instead.

--Matt

link publish delete flag offensive edit

answered 2009-12-18 00:21:51 +0800

jumperchen gravatar image jumperchen
3909 2 8
http://jumperchen.blogspo... ZK Team

Hi,

Yes, you can refer to the new smalltalk ZK 5: Chat with Event Queue.

link publish delete flag offensive edit

answered 2009-12-18 05:49:30 +0800

timo18146 gravatar image timo18146
189

I have a diffrent approach I use in a listmodel.

I built a wrapper as singleton and registered it as Attribute in App-Scope - so it is used in all sessions and Desktops. Perfectly works.

This might be a much easier way.


Cheers,

Timo Goetze
ServerPlusPlus Ltd

link publish delete flag offensive edit

answered 2009-12-19 16:20:58 +0800

mpassell gravatar image mpassell
54 3
http://blog.grovehillsoft...

@jumper Thanks, I saw that. I'll give it a closer look.

@Timo I think a ListModel would be a close enough analog. Could you describe what you did in a bit more detail? For me, the hard part isn't figuring out how to share the singleton, it's making sure that the ZK events (TreeDataEvents in the case of a TreeModel, ListDataEvents for a ListModel) are fired to all of the Desktops on the correct threads. Is there an easy way to do this that I'm just missing?

Thanks,
Matt

link publish delete flag offensive edit
Your reply
Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Question tools

Follow

RSS

Stats

Asked: 2009-12-07 11:46:46 +0800

Seen: 483 times

Last updated: Dec 19 '09

Support Options
  • Email Support
  • Training
  • Consulting
  • Outsourcing
Learn More