Thanks for the tip!  That makes a lot of sense to me, but I'm a little confused 
about
implementation.  Does it make a difference 'when' in the lifecycle I set the 
variables?

For example, suppose the user enters the URL for my create page: */create.jsf
Then, there will be no attributes stored on the page.  So, I create them, but 
that occurs 
in the render response phase of the page:

    RequestContext.getCurrentInstance().getPageFlowScope().put("createdVar", 
Boolean.FALSE);
    Boolean [] createdArr = new Boolean[ 1 ];
    createdArr[ 0 ] = Boolean.FALSE;
    RequestContext.getCurrentInstance().getPageFlowScope().put("createdArr", 
createdArr);

Then, when the user presses 'save' on the page, then the save method runs, in 
which I update the
variables:

    RequestContext context = RequestContext.getCurrentInstance();
    context.getPageFlowScope().put("createdVar", Boolean.TRUE);
    Boolean [] createdArr = (Boolean []) 
context.getPageFlowScope().get("createdArr");
    createdArr[ 0 ] = Boolean.TRUE;

When I press the 'back' button, then neither of these attributes exist on the 
page--it's as though
the user had re-entered the page URL.

So, I think I'm missing an important piece--how do I make sure the page 
attributes are stored on
the page to begin with?  or is there no way to do that?

Thanks again for your help,

--David

--- Adam Winer <[EMAIL PROTECTED]> wrote:

> Sure, what you do is:
> - Store a token - Integer, String, enum, anything you want, that indicates
> what page you're on, just like you're doing now.  As you know, this will be
> restore when the back button is hit.
> 
> - In addition to storing that token right on the pageFlowScope, also set it
> into a one-element array on the pageFlowScope - but don't create a new array
> each time, just keep writing into that first element.
> 
> The one-element array will *not* be restored to its prior state, because
> it's still the same instance.  Consequently, when you go back a page, you'll
> see that the token directly on the page won't match the token within the
> array.  Back button detected!
> 
> You could encapsulate this strategy into a reusable object if desired.
> 
> -- Adam
> 
> 
> 
> On 6/11/07, D. Cardon <[EMAIL PROTECTED]> wrote:
> >
> > Thanks, that clarifies the documentation.
> >
> > So, my follow-up question would be: Is there any way that I can detect in
> > Trinidad that the user
> > has gone from one page to the next one and then back again?
> >
> > Thank you for your help,
> >
> > --David
> >
> > --- Adam Winer <[EMAIL PROTECTED]> wrote:
> >
> > > On 6/8/07, D. Cardon <[EMAIL PROTECTED]> wrote:
> > > > Hi *,
> > > >
> > > > I'm a little uncertain about how the pageFlowScope interacts with the
> > browser's Back button.
> > > The
> > > > documentation states:
> > > >
> > > >   "...clicking the Back button will automatically reset the page flow
> > scope to its original
> > > > state."
> > > >
> > > > Which 'original state' is this referring to?
> > > >
> > > > For example, suppose I have this situation:
> > > >
> > > > I have a wizard application.  On the first page of the wizard, the
> > user should enter a
> > > username
> > > > and password and then proceed to the next page of the wizard.
> > > >
> > > > When the first page of the wizard loads, the username and password
> > fields may be entered into.
> > > > The page that takes the user to the first wizard page creates a "mode"
> > variable in the page
> > > flow
> > > > scope and sets it to "create".
> > > >
> > > > After entering valid information, the user presses the "next" button
> > on the wizard.  In
> > > processing
> > > > the command button, the code sets the page flow scope variable "mode"
> > to "wizard".
> > > >
> > > > When on the second page of the wizard, the user then presses the
> > "back" button.  What is the
> > > value
> > > > of the "mode" variable in the page flow scope? "create" or "wizard"?
> > >
> > > It's "create".
> > >
> > > -- Adam
> > >
> > > >
> > > > I would like to prevent the user from re-entering the username and
> > password after browsing
> > > "back"
> > > > to the first page of the wizard.  I thought I could use the
> > pageFlowScope to do that, but
> > > maybe
> > > > there is a better way.  Any suggestions?
> > > >
> > > > Thanks,
> > > >
> > > > --David
> > > >
> > > >
> > > >
> > > >
> > ____________________________________________________________________________________
> > > > Get the free Yahoo! toolbar and rest assured with the added security
> > of spyware protection.
> > > > http://new.toolbar.yahoo.com/toolbar/features/norton/index.php
> > > >
> > >
> >
> >
> >
> >
> >
> > ____________________________________________________________________________________
> > Don't pick lemons.
> > See all the new 2007 cars at Yahoo! Autos.
> > http://autos.yahoo.com/new_cars.html
> >
> 



       
____________________________________________________________________________________
Yahoo! oneSearch: Finally, mobile search 
that gives answers, not web links. 
http://mobile.yahoo.com/mobileweb/onesearch?refer=1ONXIC

Reply via email to