PureMVC Architects Lounge

Announcements and General Discussion => General Discussion => Topic started by: wssbwssb on January 17, 2008, 03:11:19



Title: Which part to parse the loaded xml
Post by: wssbwssb on January 17, 2008, 03:11:19
Hi cliff:
   
    I got a question recently.

    I used puremvc in my Flash application and it need a defined xml files to get the data support.
    Then I considered to construct a proxy instance. The proxy instance need the data in this xml file and it in chager of load the xml itself.

    But later on ,I found there are a lot of data get together in this xml file and other proxies need these data,too. Then I have no idea where to put my parse code and also questioned about whether to put the load xml code in that proxy instance.

    Then I think to put the load xml code and parse code into a command.But I'm also think the command can't have the ability to retrieve data from server.

     I'm so confused about this.
   


Thanks

Daniel


Title: Re: Which part to parse the loaded xml
Post by: Joel Hooks on January 17, 2008, 08:36:54
Cliff will probably reply with a more correct solution, but since you are frustrated and confused I thought I would offer my solution to your problem.  ;)

I don't think there are any 'rules' against proxies communicating and sharing data, so in your ModelPrepCommand initialize only the XML data proxy. When it has finished loading and parsing the XML send a notification to start another command that adds the other proxies to the system. These proxies can then grab instances of your XML data proxy and go about their business.


Title: Re: Which part to parse the loaded xml
Post by: puremvc on January 17, 2008, 10:02:23
Daniel,

For an example, please examine the Proxies of the CodePeek application.

In short you've got a big xml tree with smaller xml branches inside it.

You want the proxy in charge of the big tree to snap off the twigs, create the appropriate proxies for them and register the proxies. QED.

The cool thing about it is that if you pass the new proxies references to the nodes in the big tree (rather than copies), then as the data in the twigs (accessed through their proxies) will automatically be updating the data in the big tree.

-=Cliff> 


Title: Re: Which part to parse the loaded xml
Post by: wssbwssb on January 20, 2008, 07:23:15
Hi Joel Hooks and cliff
   
    thank you for your reply.
    This really help me a lot:)

Daniel