Adobe Dreamweaver Forums



Last 10 THreads :         Re: Your techiques for removing specular from photos (Last Post : Don_Gough@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: Colour differences on the web (Last Post : g_ballard@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: Colour differences on the web (Last Post : Jim_Jordan@adobeforums.com - Replies : 0 - Views : 1 )           »          Re: Printing too dark in CS4 (Last Post : Tom_H_Mikkelsen@adobeforums.com - Replies : 0 - Views : 1 )           »          button rollover to keyframe help (Last Post : mrpetesurfs - Replies : 2 - Views : 3 )           »          How to turn IMAGE into MOVIECLIP??? (Last Post : Snufferson - Replies : 21 - Views : 22 )           »          What is the best way to get the minimum or maximum valuefrom an Array of numbers? (Last Post : ericbelair - Replies : 4 - Views : 5 )           »          Scaling .swf files to fit specific dimensions (Last Post : mrpetesurfs - Replies : 1 - Views : 2 )           »          Stop ALL Sounds (Last Post : mrpetesurfs - Replies : 1 - Views : 2 )           »          Stop looping??? (Last Post : mrpetesurfs - Replies : 2 - Views : 3 )           »         


Home Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
User Info Statistics
Go Back   Adobe Dreamweaver Forums > Macromedia Software > Flex
 
Tags:



Reply
  #1 (permalink)  
Old 11-03-2008, 04:38 AM
sjerry-
 
Posts: n/a
Diggs:
Default Where to plave groupingcollection.refresh() in Cairngormdesign?

I wonder where to place the functionality to refresh a groupingcollection, in
an advanceddatagrid, inside the Cairngorm framework?

Situation:
I have an advanceddatagrid with a groupingcollection for displaying product
data. When the application is initialized, the getProductsEvent is dispatched.
This will invoke the getProductsCommand wich will invoke getProductsDelegate.
The delegate gets the data from the server and the command (wich implements the
IResponder interface) will transform the data into an ArrayCollection and
assign it to ShopModelLocator.getInstance().products.

Problem:
The problem is that the view (AdvancedDataGrid) is not updated after changed
model.products. To do this, you have to invoke GroupingCollection.refresh().

Question:
The model doens't need to know the view. So invoke
GroupingCollection.refresh() from the getProductsCommand is not an option. What
is the best location to implement the logic that refreshes the
groupingCollection? What is best practise?



Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-03-2008, 04:38 AM
mhartnett
 
Posts: n/a
Diggs:
Default Re: Where to plave groupingcollection.refresh() inCairngorm design?

We struggled with this exact issue at the beginning of using Cairngorm as well
and here are our solutions. I don't know if they are best practices since I
could not find much info on the problem.


Add a object capable of dispatching events in your model object.
public var xmlDataLsnrO : ObjectProxy = new ObjectProxy(new Object());


In any object that needs to be notified that a change to data has been made we
added the code ( this code exists in our base class data grid so it is
available to any object that extends the baseGrid)

//this adds a new ArrayCollection to the listner object in the model.
//The dataKey can be whatever you want to use. In your case it could possibly
be "groupingData".
if(model.xmlDataLsnrO[dataKey] == null)
model.xmlDataLsnrO[dataKey] = new ArrayCollection();

//The next lines add listeners to the object that contains the datagrid. It
combines the dataKey with a set of standardized data event listener names. In
the next lines we add three listeners. One for save, one for delete, and one
for the initial load of the data. Each event has a coresponding listener
method.

var o1: ArrayCollection = model.xmlDataLsnrO[dataKey] as ArrayCollection;
o1.addEventListener(dataKey + "SaveEvent",dataSavedHandler);
o1.addEventListener(dataKey + "DeleteEvent",dataDeleteHandler);
o1.addEventListener(dataKey + "LoadEvent",dataLoadHandler);

In the command object we added the following code. Again this code is very
generic because it has been taken from some base classes. We use the parmObj
to maintain the requestKey which would be the same as the dataKey from the
previous step
//parmObj.requestKey would be equal to the dataKey defined in the previous
step.
//Get the arrayCollection out of the model listener object.
var o1: ArrayCollection = model.xmlDataLsnrO[parmObj.requestKey] as
ArrayCollection;

//if the object exists then dispatch an event to any listener. Since your
object that contains your datagrid object added itself to the arrayCollection
then it will be notified of the data change. We have created a specific Event
type for save, delete and load but you can use a plain old Event. Our save
event actually passes the updated item to the method. Not really necessary
if(o1 != null)
o1.dispatchEvent(new DataSaveEvent(updatedItem as Object, parmObj.requestKey +
"SaveEvent", "success"));

In your datagrid object there is a method that get executed upon being
notified. In this case it would be after a data save.

protected function dataSavedHandler(dse : DataSaveEvent) : void {
//do whatever you want to do here to refresh the grid.
}


That is about it. It give you the ability to add multiple object that want to
be notified of changes to the arrayCollection. So if 3 screens need to be
notified of changes to the groupingCollection you would just need to add them
to the model listener arrayCollection for the key of groupingData.

You need to remember to remove these listeners whenever the screen closes.
This is very important so that memory will be cleaned up. Hope this is clear.

Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
All times are GMT. The time now is 09:46 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
Cheap Car Insurance - Compare Motor Insurance
Endsleigh Car Insurance Natwest Car Insurance
More Than Car Insurance Norwich Union Car Insurance
Prudential Car Insurance Zurich Car Insurance
Inactive Reminders By Mished.co.uk