Question

After login, I am navigating from Login ViewStack to Application ViewStack in Flex 4 AIR application.

In the Application ViewStack, datagrids and other controls are populated with data from server.

Now, on logout, I am switching back to Login ViewStack. However, on login again, I can see data populated earlier.

How could I reset all the fields in Application ViewStack on logout. I thought of 2 approaches:

1. Reset all fields in the Application ViewStack individually. But, then for every addition of control, I have to update logout.
2. Could I use navigateToURL() in AIR application to solve this problem?
Was it helpful?

Solution

From your description I'm a little confused - I'm assuming that your application ViewStack has a number of different views, and you need to have each of them clear their state when logout occurs.

I can think of a couple of ideas: 1) Have each of the views add an event listener for a logout event, and dispatch the event when logout occurs. The event listener would clear the data when logout occurs.

2) Iterate through the ViewStack children, and call a logout method on each one.

My personal preference is for (1), since (2) requires that all the children of the ViewStack implement the logout method - too tightly coupled for reuse.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top