If you want to take a look at Cairngorm, this is an excellent example application developed using Cairngorm and was my first approach to the framework. It's not a simple example, but it explains a lot of things. Additionally, you should take a look at references on each base class and interface that is implemented (FrontController, IResponder, ICommand, etc). http://www.adobe.com/devnet/flex/articles/image_viewer.html
And here: http://www.adobe.com/devnet/flex/articles/cairngorm_pt1.html there's a full article that was really useful to me too. Best regards. Andrea On Thu, Nov 5, 2009 at 12:27 PM, Andrea Giorgetta <andreagiorge...@gmail.com > wrote: > I agree with Vaibhav, you should use Cairngorm because it's a great > framework that simplifies many repetitive tasks and "forces" the developer > to create a better class model. > For this particular problem, it is not necesary, this > "Kindof-ModelLocator-Singleton-Pattern" can be implemented anyway. > Solved it by changing: > > 1. [Bindable] to full SingletonXML class. Sorry I miss that one in the > first example. > 2. private var _data: ... to public var data, and remove the getter. > Not sure why's that... :S > > Attached my test code. > > Hope this works. > Andrea > > > > > > On Thu, Nov 5, 2009 at 11:51 AM, Kiran Kumar Vasireddy < > kiranv...@gmail.com> wrote: > >> Hi Dinukx, >> >> Thanks for your response and Could you please help me on IResponder >> interface ? I googled but no use >> >> >> Hi Andrea, >> >> Following is the format of XML data data we received .I just took the >> format from the XML and changed the names . Data we received is about 3 MB >> file and it is live data. Country,State,City and Student tags are repeated >> >> >> <Edu > >> <Country name="United States" code="US"> >> <State name="Michigan" code="MI"> >> <City name="Auburn Hills"> >> <Student name="Kiran " /> >> <Student name = "Abhijith" /> >> </City> >> </State> >> <State name="Ohio" code="OH"> >> <City name="Coshocton"> >> <Student name="Andrea" /> >> <Student name = "John" /> >> </City> >> </State> >> </Country> >> </Edu> >> >> Regards >> Kiran >> >> >> >> On Wed, Nov 4, 2009 at 11:53 PM, flexorz group of flex corders < >> flexco...@gmail.com> wrote: >> >>> i think Vaibhav solution should work ,but you have to update the model >>> from the command it self. (try to look in to more Cairngorm solutions). only >>> putting [binding] tag wont do the trick :) >>> >>> the second option should be using and responder.(you may need to >>> implement IResponder interface) >>> >>> where you can create the asynchronous call and wait until the result is >>> passed back to the result function or falut. >>> >>> actually thats how even cairngrom works. >>> >>> let me know if you need any help on that. >>> >>> thanks >>> dinukx >>> >>> >>> >>> let me know if you need help with responder >>> >>> Dinukx; >>> >>> POC : >>> >>> >>> >>> >>> >>> On Thu, Nov 5, 2009 at 1:08 AM, Kiran Kumar Vasireddy < >>> kiranv...@gmail.com> wrote: >>> >>>> Hi Vaibhav, >>>> >>>> Sorry no use ,still not working . >>>> >>>> Regards >>>> Kiran >>>> >>>> >>>> On Wed, Nov 4, 2009 at 12:38 PM, Vaibhav Seth < >>>> seth.vaibhav...@gmail.com> wrote: >>>> >>>>> To avoid such kind of issues, better use Cairngorm. >>>>> I doubt the problem is Binding. You have to bind data with the >>>>> dataprovider of your component. So that, whenever your data will get >>>>> populated it will be reflected in the component. Try using: >>>>> [Bindable]private var _data:XMLList; >>>>> >>>>> >>>>> >>>>> >>>>> >>>>> On Wed, Nov 4, 2009 at 11:59 AM, Kiran Kumar Vasireddy < >>>>> kiranv...@gmail.com> wrote: >>>>> >>>>>> Thanks Vaibhav and Andrea for your suggestions. >>>>>> >>>>>> Andrea : You suggestion looks working , But got in one more problem . >>>>>> Could you please help me ? >>>>>> >>>>>> If I call SingletonXML.getInstance().data; It is returning Null >>>>>> because the of getResult() is returning the data later . Since the calls >>>>>> are >>>>>> asynchronous get Data() is getting called first and then getResult(). >>>>>> >>>>>> I checked the event data and data is there in the event . >>>>>> >>>>>> I came into this problem because of "<XML source = "is crashing my >>>>>> IE7, Otherwise I could have done it using XML tag instead HTTPService ( >>>>>> for >>>>>> local data I am using HTTPService ) . Please see the code below. >>>>>> >>>>>> >>>>>> >>>>>> package Components >>>>>> { >>>>>> import mx.controls.Alert; >>>>>> import mx.rpc.events.ResultEvent; >>>>>> import mx.rpc.http.HTTPService; >>>>>> >>>>>> >>>>>> public class SingletonXML >>>>>> { >>>>>> private static var _instance: SingletonXML; >>>>>> private var _data:XMLList; >>>>>> >>>>>> public function SingletonXML() { >>>>>> >>>>>> if (_instance != null) >>>>>> trace("Constructor shouldn't be called >>>>>> directly... now I'll have to kill you") >>>>>> _instance = this; >>>>>> this.initData(); >>>>>> } >>>>>> >>>>>> private function initData():void { >>>>>> var service:HTTPService =new HTTPService(); >>>>>> service.url="Components/StudentData.xml"; >>>>>> service.resultFormat="e4x"; >>>>>> service.addEventListener("result", getResult); >>>>>> service.send(); >>>>>> >>>>>> } >>>>>> private function onDataLoaded():void { >>>>>> >>>>>> //Store data >>>>>> //this._data = [loaded data]; >>>>>> >>>>>> } >>>>>> >>>>>> private function getResult(event:ResultEvent):void{ >>>>>> Alert.show("this is in get result"); >>>>>> >>>>>> _data=XMLList(event.result.Country); >>>>>> >>>>>> } >>>>>> >>>>>> public static function getInstance():SingletonXML{ >>>>>> if (! _instance) >>>>>> _instance = new SingletonXML(); >>>>>> >>>>>> return _instance; >>>>>> } >>>>>> >>>>>> public function get data():XMLList { >>>>>> Alert.show("this is in get data"); >>>>>> return this._data; >>>>>> >>>>>> >>>>>> } >>>>>> } >>>>>> } >>>>>> >>>>>> On Tue, Nov 3, 2009 at 4:38 PM, Andrea Giorgetta < >>>>>> andreagiorge...@gmail.com> wrote: >>>>>> >>>>>>> Hi Kiran. >>>>>>> I think you should create a "ModelLocator" singleton class, that gets >>>>>>> and store the xml information. It would be something like this: >>>>>>> >>>>>>> public class MyModelLocator >>>>>>> { >>>>>>> private static var _instance: MyModelLocator; >>>>>>> private var _data:XMLList; >>>>>>> >>>>>>> public function MyModelLocator() { >>>>>>> if (_instance != null) >>>>>>> trace("Constructor shouldn't be called directly... >>>>>>> now I'll have to kill you") >>>>>>> _instance = this; >>>>>>> this.initData(); >>>>>>> } >>>>>>> >>>>>>> private function initData():void { >>>>>>> //Load data.... >>>>>>> } >>>>>>> private function onDataLoaded() { >>>>>>> //Store data >>>>>>> this._data = [loaded data]; >>>>>>> } >>>>>>> >>>>>>> public static function getInstance():MyModelLocator{ >>>>>>> if (! _instance) >>>>>>> _instance = new MyModelLocator(); >>>>>>> return _instance; >>>>>>> } >>>>>>> >>>>>>> public function get data():XMLList { >>>>>>> return this._data; >>>>>>> } >>>>>>> } >>>>>>> >>>>>>> In order to get data in each combobox, you would set >>>>>>> dataprovider="{MyModelLocator.getInstance.data}" (if that XMLList >>>>>>> already >>>>>>> has the correct structure to be directly used as a dataprovider in the >>>>>>> combobox... otherwise now is the time to change it ;) ) >>>>>>> This way: >>>>>>> - There's only one instance of MyModelLocator at anytime, anywhere. >>>>>>> - initData is called only once, so the data is retrieved only once. >>>>>>> - By storing the data within the singleton class, it's available to >>>>>>> the whole application by just importing the class. >>>>>>> >>>>>>> >>>>>>> Hope it solves your issue. >>>>>>> Best regards >>>>>>> Andrea. >>>>>>> >>>>>>> >>>>>>> >>>>>>> >>>>>>> On Tue, Nov 3, 2009 at 5:59 PM, Kiran Kumar Vasireddy < >>>>>>> kiranv...@gmail.com> wrote: >>>>>>> >>>>>>>> Hi , >>>>>>>> >>>>>>>> I am calling httpservice.send() method and getting the data and >>>>>>>> populating it in XMLList . I want this step to be done only once and >>>>>>>> want to >>>>>>>> reuse the data what ever I got . >>>>>>>> My scenario is like this >>>>>>>> >>>>>>>> 1)Creating Custom combobox component >>>>>>>> 2) Calling send() in the custom component and populating the >>>>>>>> combobox >>>>>>>> >>>>>>>> I want to create around 5 instances of the above component . But >>>>>>>> what is happening is the send() is getting called again and again . Is >>>>>>>> there >>>>>>>> any way to restrict this and get the data only once and use it for my 5 >>>>>>>> instances . The problem here is If I use http send() method when I >>>>>>>> load the >>>>>>>> application , This works perfect . But we want that to be called only >>>>>>>> from >>>>>>>> component and want to use the same component again and again. >>>>>>>> >>>>>>>> Thanks for your help >>>>>>>> Kiran >>>>>>>> >>>>>>>> >>>>>> >>>>>> >>>>>> >>>>> >>>>> >>>>> -- >>>>> Thanks, >>>>> Vaibhav Seth. >>>>> >>>>> >>>>> >>>>> >>>> >>>> >>>> >>> >>> >>> >> >> >> >> > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Flex India Community" group. To post to this group, send email to flex_india@googlegroups.com To unsubscribe from this group, send email to flex_india+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/flex_india?hl=en -~----------~----~----~----~------~----~------~--~---