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
<[email protected]>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 <
> [email protected]> 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 <
>> [email protected]> 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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/flex_india?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to