Hi,

The history manager saves and loads state properties for registered
components; not ModelLocator state variables.  Each time that the
selectedChild of the ViewStack changes, the history manager saves the
ViewStack's selectedIndex. When the browser's back button is clicked,
the history manager loads and sets the ViewStack's selectedIndex to the
previous value.  This bypasses the binding of selectedChild and does not
update model.workflowState to the current view's value.  So when you
click the back button to return to Page1 from Page2, model.workflowState
is still stuck at ModelLocator.PAGE_2.  Since clicking the linkText to
go to Page2 updates model.workflowState to ModelLocator.PAGE_2, the
binding isn't notified of the change; because the variable's value isn't
being changed.

You can write some custom history management by implementing
IHistoryManagerClient.  Or, you could try:

<view:Page1 id="somePage1" show="showPage(1)"/>
<view:Page2 id="somePage2" show="showPage(2)"/>
<view:Page3 id="somePage3" show="showPage(3)"/>

This is kind of a hack, but it should keep you state variable in sync
with the current view.

-TH

--- In flexcoders@yahoogroups.com, "srieger_1" <[EMAIL PROTECTED]> wrote:
>
> Hi All,
>
> I am having an issue with the ViewStack when the user clicks the back
> button. The browser takes them back a page however, my Flex
> application doesn't recognize the change thus none of my links work on
> the previous page. Let me give an example as that sounds confusing.
>
> The user is viewing a page in my application. Lets call it page one.
> On page one the user clicks a link to go to page 2. Now the user is
> viewing page 2 and clicks the back button to go back to page 1. For
> some reason the link to page 2 no longer works. I found if the user is
> viewing page 2 and clicks a button or link that use flex code to
> navigate to Page 1, anything besides the back button, then the links
> on page 2 will work. Below is some sample code of how I am working
> with the ViewStack Links and Buttons . . .
>
> Thanks for any help you can offer .. . ..
>
> private function showPage( pageNumber : Number ) : void
> {
> switch( pageNumber )
> {
> case (1) :
> model.workflowState = ModelLocator.PAGE_1;
> break;
> case (2) :
> model.workflowState = ModelLocator.PAGE_2;
> break;
> case (3) :
> model.workflowState = ModelLocator.PAGE_3;
> break;
> }
> }
>
> public function getView( workflowState : Number ) : Container
> {
> switch( workflowState )
> {
> case ( ModelLocator.PAGE_1 ) :
> return somePage1;
>
> case ( ModelLocator.PAGE_2 ) :
> return somePage2;
>
> case ( ModelLocator.PAGE_3 ) :
> return somePage3;
> }
>
> return pageError;
> }
>
> <mx:ViewStack id="appView" width="100%" height="100%"
> selectedChild="{getView( model.workflowState )}"
> historyManagementEnabled="true">
> <view:Page1 id="somePage1" />
> <view:Page2 id="somePage2" />
> <view:Page3 id="somePage3" />
> </mx:ViewStack>
>
>
> <mx:Text styleName="linkText" text="Link to Page 2"
> mouseChildren="false" buttonMode="true" useHandCursor="true"
> click="showPage(2)"/>
> <mx:Button label="Go to Page 1" click = "showPage(1)"/>
>



Reply via email to