tags:

views:

22

answers:

3

Let's say I have an Employee, and for the creation of such employee in my web application I want to follow the next flow.

Create <-> Verify -> Save

In the create page the user can set up a bunch of properties, In the verify page the user is presented with two options "make changes" and "verify" In the save page the user is presented with a confirmation page

I have two approaches to this:

  1. Use Javascript to change "action" and "method" of the form.

  2. Handle the logic on the action (which feels kind of clunky at least with asp.net mvc)

Which do you prefer ?

Is there a better way to do this?

A: 

Pretty easy in ASP.NET MVC. See these posts for guidance:

http://stackoverflow.com/questions/297148/how-to-make-a-wizard-with-asp-net-mvc http://shouldersofgiants.co.uk/Blog/post/2009/09/16/A-RESTful-Wizard-Using-ASPNet-MVCe280a6-Perhaps.aspx

Personally, I would do it as a single GET/POST and utilize some basic jQuery to show/hide DIVs containing the necessary inputs as noted in the first link.

Nissan Fan
A: 

I would do this with routes

GET new to render the create form  
POST new to show the verify form 
POST create to actually create the resource
Matt Briggs
A: 

Create <-> Verify -> Save

It isn't clunky, Create is Get, verify is post of the same URL. The method that handles the Get and the one that does the post use the Same View, just with different info sent to it.

So for the create the view is instructed to post to the same Url, when u are already to verify it will post to the Save action.

The above works for any non js client. You can then hook some js, so instead of posting the form from Create -> Verify, you would change in the client side. This way it works for both js - non js versions. You can even display the Save confirmation with the same technique if you wanted. Progressive Js.

eglasius