0

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?
Vikas Sharma
  • 1,235
  • 2
  • 27
  • 53

1 Answers1

0

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.

Bill Turner
  • 980
  • 1
  • 6
  • 23
  • The event listener would clear the data when logout occurs. But, I have to individually clear each and every controls in the view. And every time, new control added in view, I have to change the logout event method. I am looking for method that will clear all the data in one command. Like, we have reset in HTML. – Vikas Sharma Mar 29 '13 at 08:50
  • @VikasSharma I think you are suffering from a few misunderstandings concerning Flex apps and architecture. – Black Dynamite Mar 29 '13 at 14:57
  • Yes FlexFiend, I have just started working on Flex for couple of days. Anyways, I am going with event listener as recommended by Bill. – Vikas Sharma Apr 01 '13 at 07:01