Michael,
 
In 1.0, we've added something to the ViewHelper which adds an unregisterView() method on the
ViewHelper - I think we posted the code for this to flexcoders before; if not, drop Alistair or I an
email and we'll pass it on to you.
 
From the archives:
 
 
Best,
 
Steven


From: Michael Herron [mailto:[EMAIL PROTECTED]
Sent: 07 March 2005 13:40
To: [email protected]
Subject: [flexcoders] Cairngorm view helpers and dynamic loading of content

Hi all

 

Currently, I have a framework where separate “modules” are loaded in to a central panel using the createChild method. The reason for using this method as opposed to a view stack for example is the amount of these “modules” that I could potentially have is huge and it seems easier/cleaner to load the modules when required. And also, correct me if im wrong, but if a view stack was used, would each module not be loaded upon first navigating to it and then be retained in memory?

 

When the user first selectsa menu option and the required module is loaded, all works fine.  The user may then navigate to another module, whereupon the initial module is destroyed using the destroyAllChildren method and the new module loaded. The problem occurs if the user then tries to return to the original module. The module will attempt to register its view helper which will in turn cause the view locator to throw an error, as the view name has already been registered in the array of view helpers - even though the view and view helper where destroyed when the new module was loaded. This is also problem for reusable components that are being made use of inside the modules.

 

To confirm that this was the problem, I commented out the view locators error checking and all worked fine. The way I see it, the only solutions are:

 

·         Use a view stack and switchthe selectedIndex rather than using createChild/destroyChild – perhaps this should have been the correct design choice used in the first place? Using this method the components problem is also solved as the view can be registered through action script with the “view already exists” error being caught, and just reassigning the view attribute of the existing view helper to point to the existing instance of the component.

 

·         Add a forceRegister method to the view locator that will not perform the check for an existing view, write my own view helper class that will override the set name method and call this method. This method is obviously not ideal. Cairngorm is a solid framework and things like existing view helper checking exist for a reason.

 

Any thoughts/suggestions?

Cheers,

Mike Herron 

Reply via email to