In one of the States ("HotelUserState") of my application I have a component (HotelList) within a component (HotelUser). The idea is that the user can choose which Hotel it wants to add/delete/mod users using the HotelList component, and once chosen it will send an event to HotelUser so it may change to a sub State to show a user List.
The problem is that if i navigate away once I've chosen a user and then come back to this State... i will still see the last screen shown, the component won't show data, also data is not refreshed (say if i create a new hotel...). I would like it to start from scratch everytime, but i cannot seem to get it. I know enterState
This is how in my main app the state called when selected from a menubar:
<mx:State name="HotelUserState" >
<ns1:HotelUser x="53" y="72">
Then my HotelUser component looks like this (simplified):
<mx:Canvas xmlns:mx="http://www.adobe.com/2006/mxml" width="710" height="502" xmlns:ns1="components.*">
<ns1:HotelList id="hotelList" horizontalCenter="0" verticalCenter="-21">
In short, how can I have the HotelList component refreshed/recreated it time it is shown so it pulls recent info?I know it must be something really basic... but i cannot seem to be able to do it.
Any hints are welcome! thank you!
recreating component - not a good idea.
It's better to use it as a dataRenderer.
Your HotelList should have something like dataProvider or data property. So by changing it inner data should change.
Thanks for your reply, Now the question would be: since im trying to make the HotelList component as reusable as possible, where do you think should this DataProvider (a Bindable ArrayCollection in my case) be placed? In the main MXML file where it is updated when an event is triggered? Or in a Singleton somewhere?
Thanks a lot!
It depends on what you need...
For Cairngorm architecture it should be in a model (in a Singleton).
But if you have not a big application you can change it directly.