views:

210

answers:

2

Hi

I have creating a distributed note taking application in flex, it basically is a notepad I can keep in my desktop tray. When I add notes and goes back to a server and saves it in a database.

To am struggling to design the application correctly, I want to have a Syncing service that polls the webserver for changes and updates an Array of Note objects. The problem is that my note corresponds mxml component, aka SingleNote component. There are four different cases when being, a. a note is updated from the server poll, in that case I want to singlenote to update the settings b. a note is added to the array from the server, in that case a new SingleNote needs to be created c. a SingleNote is added from client, in that case a Note is added to array, and sent back to server d. a SingleNote is change from client, in that case the Note is updated in the array and sent back to server

The properties are SingleNote(Width, X, Y, Text).

Can you recommend how to achieve this complex databinding? How would you design this?

A: 

Hello,

Do you find a solution to your problem because I have the same.

Regards,

Rom

+1  A: 

What does your database look like? Is there any Note table in it?

I guess services on the service side are already done if you're asking for a client architecture. In that case, what's the structure of the data that is exchanged between your client and server?

The best case is if you already have a DTO/VO that map the note entity from your database to a class. On the client side, You can then use the id field of each object to know if it's already saved to the database or not.

So, what I would do is:

Create a NoteManager on the client side which:

  1. stores your array of Note objects
  2. have methods that manage the state of this array : hasNote(idNote:int), addNote(note:Note), removeNote(idNote:int), updateNote(idNote:note),...

When you modify the state of this array, you have to update your view(s). Depending of what framework you use (if you use any), this can be done in different ways, but the general idea is to use the Observable pattern to update your view after a model change. (Somewhere , you might also have a Map that maps a note object to its component display)

PeZ