This is how I would do it using Cairngorm:
 
I would have the following in my Model :-
 
1) static vars representing my viewstate --
 
  public static var VIEWING_RUN_SCENARIOS:uint = 0;
  public static var VIEWING_DEC:uint = 1;
  public static var VIEWING_MONITOR_RESULTS:uint = 2;
  public static var VIEWING_CREATE_SCENARIOS_ARBITRARY:uint = 3;
...
 
 
2) var viewState that always contains one of the above mentioned views
and is tied to the ViewStack being manipulated by my navigator --
 
<mx:Binding source="model.viewState"
destination="appstack.selectedIndex"/>
 
 
3) a modified:Boolean flag that is set to true any time a formelement is
edited
 
 
4) initView() function that is invoked everytime a view change is
intended using any navigator.
 
This has an Alert.Show which decides to change the viewState or not. On
OK, change the viewState and reset the modified flag. On Cancel, just
return.
 
 
Not using cairngorm you could still perhaps emulate the singleton data
structure of a Cairngorm Model and have a single place to store your
view, its state and manage its transitions.
 
Best of luck
Aman
LB | Tokyo

________________________________

From: [email protected] [mailto:[EMAIL PROTECTED] On
Behalf Of Flexing...
Sent: Monday, May 21, 2007 1:33 PM
To: [email protected]
Subject: [flexcoders] Navigating away from a Tab



Hi All,

I have a tab navigator each containing a form where user needs to 
fill some information.

Now what I want to do is that if a user tries to move away from a Tab 
without completing or saving the information,
I want to show an Alert (Changes will be lost if you navigate away 
from the page. Continue .. yes/no) and
want to move to other tab only after use clicks Yes on this alert.

How can I implement this in Flex ?

One solution I thought of is:
1. Add a listener for the "change" event.
2. Store a flag for the tab. Switch it on when an edit is made on the 
form (how do I track edits!!)
3. On Tab change see if flag is on, show alert. If use clicks yes, 
just hide the alert
else
set the selected Index of the tab back to the old index.

Now the above solution will work if the Tab Navigator is the only 
navigator but if it is a child tab navigator then I will have to 
track the tab change on the parent tab navigator as well...
This will further complicate if there is Tree navigation , multiple 
ViewStacks etc etc ...

if anyone has any suggestions on how to implement this better, it 
will be great.

Thanks


 
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
- - - -

This message is intended only for the personal and confidential use of the 
designated recipient(s) named above.  If you are not the intended recipient of 
this message you are hereby notified that any review, dissemination, 
distribution or copying of this message is strictly prohibited.  This 
communication is for information purposes only and should not be regarded as an 
offer to sell or as a solicitation of an offer to buy any financial product, an 
official confirmation of any transaction, or as an official statement of Lehman 
Brothers.  Email transmission cannot be guaranteed to be secure or error-free.  
Therefore, we do not represent that this information is complete or accurate 
and it should not be relied upon as such.  All information is subject to change 
without notice.

Reply via email to