How to implement a Start Again Button on a edit view
I have an edit view that let's the user modify an object thru a number of steps. All the "steps" redisplay the same view with additional/changed information. Once all the information has been entered there is a Save button to make the changes permanent. I want to have a "Start Again" button that the user can press at anytime to discard all the changes and start again in the same view. In the startAgain() action I reset all the backing beans properties from the saved original object. The problem is the view components still have the last values displayed. (I've tried both an Action and ActionListener and get the same result.) The form that gets redisplayed to the user has the last values displayed NOT my backing bean property values. Is this because the "Update Model Values" phase was skipped? Is there a way to reset the view so it acts like this is the first time. I want the view components to get all there values from the bound backing bean properties like they normally would following a non immediate action event. Can anyone help? Using MyFaces and Tomahawk 1.1.1.
Re: How to implement a Start Again Button on a edit view
You could probably create a second navigation rule which includes and activate it after your've updated your view. That should start the page out as if you were going to it again for the first time, provided you've reset everything stored in session and application scope. On 4/4/06, Lindholm, Greg <[EMAIL PROTECTED]> wrote: > I have an edit view that let's the user modify an object thru a number > of steps. > All the "steps" redisplay the same view with additional/changed > information. > Once all the information has been entered there is a Save button to make > the > changes permanent. > > I want to have a "Start Again" button that the user can press at anytime > to > discard all the changes and start again in the same view. > > > > In the startAgain() action I reset all the backing beans properties from > > the saved original object. The problem is the view components still have > > the last values displayed. > (I've tried both an Action and ActionListener and get the same result.) > > The form that gets redisplayed to the user has the last values displayed > > NOT my backing bean property values. > > Is this because the "Update Model Values" phase was skipped? > > Is there a way to reset the view so it acts like this is the first time. > > I want the view components to get all there values from the bound > backing > bean properties like they normally would following a non immediate > action event. > > Can anyone help? > > Using MyFaces and Tomahawk 1.1.1. > >
RE: How to implement a Start Again Button on a edit view
The does start fresh but I cannot use it because I loose my backing-bean which has the original object to be modified. My backing bean is request scope and passed around with the which doesn't work across a . Here is the REALLY INTERESTING thing The good news is it seems to work without the as long as I go thru a different navigation rule. Previously the startAgain() method was just returning null. I changed the startAgain() method to to return "startAgain" and added a navigation rule back to the same page and now it is working. So why is this working? - If I redisplay the same page without navigation the view components retain there previous values. - If I go thru navigation rules and return to the same page the view components get there values from binding to the backing bean. Is this expected/defined behaviour? Or is it a fluke? I don't want to rely on it if it may change in the next release. -Original Message- From: Mike Kienenberger [mailto:[EMAIL PROTECTED] Sent: Tuesday, April 04, 2006 3:07 PM To: MyFaces Discussion Subject: Re: How to implement a Start Again Button on a edit view You could probably create a second navigation rule which includes and activate it after your've updated your view. That should start the page out as if you were going to it again for the first time, provided you've reset everything stored in session and application scope. On 4/4/06, Lindholm, Greg <[EMAIL PROTECTED]> wrote: - I have an edit view that let's the user modify an object thru a number of steps. All the "steps" redisplay the same view with additional/changed information. Once all the information has been entered there is a Save button to make the changes permanent. I want to have a "Start Again" button that the user can press at anytime to discard all the changes and start again in the same view. In the startAgain() action I reset all the backing beans properties from the saved original object. The problem is the view components still have the last values displayed. (I've tried both an Action and ActionListener and get the same result.) The form that gets redisplayed to the user has the last values displayed NOT my backing bean property values. Is this because the "Update Model Values" phase was skipped? Is there a way to reset the view so it acts like this is the first time in? I want the view components to get all there values from the bound backing bean properties like they normally would following a non immediate action event. Can anyone help? Using MyFaces and Tomahawk 1.1.1.
Re: How to implement a Start Again Button on a edit view
On 4/4/06, Lindholm, Greg <[EMAIL PROTECTED]> wrote: > The does start fresh but I cannot use it > because I loose my backing-bean which has the original object > to be modified. My backing bean is request scope and passed > around with the which doesn't work across > a . Well, you're asking for two conflicting things. A "new" page, but also a page that isn't new (remembers the t:saveState). You could temporarily put the bean into session-scope and remove it after the redirect. > Previously the startAgain() method was just returning null. > I changed the startAgain() method to to return "startAgain" > and added a navigation rule back to the same page and now it > is working. > > Is this expected/defined behaviour? > Or is it a fluke? > > I don't want to rely on it if it may change in the next > release. I don't know. It's probably reasonable to think that you'll need a new page if you ask for it "by navigation rule" -- this would be the case in a multi-window application. Null is always supposed to return the current page. I'd probably continue with this behavior. I don't think it will change.
Re: How to implement a Start Again Button on a edit view
Hi! > You could probably create a second navigation rule which includes > and activate it after your've updated your view. > I am not sure proposing for this is the best idea. Once we have a technology in place which will survive request information this wont work any more - given the user configures the new classes. Might it help to put the commandButton into the new s:subForm tag? That way you dont have to use the immediate=true. Just a thought, dont know if it works. Ciao, Mario
Re: How to implement a Start Again Button on a edit view
On 4/4/06, Mario Ivankovits <[EMAIL PROTECTED]> wrote: > I am not sure proposing for this is the best idea. > > Once we have a technology in place which will survive request > information this wont work any more - given the user configures the new > classes. That's a good point. It does now make me wonder if the spec defines any particular behavior in this regard for . We might need to make the behavior configurable.
Re: How to implement a Start Again Button on a edit view
On 4/4/06, Mike Kienenberger <[EMAIL PROTECTED]> wrote: > On 4/4/06, Lindholm, Greg <[EMAIL PROTECTED]> wrote: > > Previously the startAgain() method was just returning null. > > I changed the startAgain() method to to return "startAgain" > > and added a navigation rule back to the same page and now it > > is working. > > > > Is this expected/defined behaviour? > > Or is it a fluke? > > > > I don't want to rely on it if it may change in the next > > release. > > I don't know. It's probably reasonable to think that you'll need a > new page if you ask for it "by navigation rule" -- this would be the > case in a multi-window application. Null is always supposed to > return the current page. > > I'd probably continue with this behavior. I don't think it will change. It looks like this behavior is mandated by the spec, so you should be able to count on it remaining constant. === 7.4 NavigationHandler 7.4.1 Overview As mentioned below, if the outcome returned by the application action is null, the same view must be redisplayed. This is the only case where the same view (and component tree) is reused..