views:

300

answers:

2

I am new in building web apps and just begun learning and setting up Grails. I am planning to build an app which has a flow of 4 to 5 pages. Since HTTP is a stateless protocol, how is the state between the pages maintained usually. I am curious what is the accepted standard here, should I create session scoped objects and use them between pages or keep passing around the values between pages (not sure if it is effective if I have a large number of items on a page). Or instead of using 4 to 5 pages should I just use one page with multiple divs and show/hide based on the user clicks? I think using domain objects in Grails would help here but I dont have a DB backing the UI and only some webservices which will do the UI actions so I cant use domain objects. A Grails specific solution would be good but also wanted to know how this is handled in web development in general.

+5  A: 

Without using a DB, there are a few options you could use:

  1. Use POST/GET variables to pass info from page to page.
  2. Use the session to store information.
  3. Use cookies to store information.

Using POST/GET is usually best if you just have one page "talking" to one other page (e.g. submission of a form). If you have a bunch of data that will be shared by several pages, the best way to do it would probably be to put them in the session. If you need those values to stick around after the user leaves your site and comes back later, then you might want to use cookies.

Eric Petroelje
Yeah rite I dont want to use a DB to store the intermediate things. I have some 50 fields on page 1 which needs to be in memory till I do a submit from page 4. So I guess I should use session storage. I will check how grails supports this.
Arvind
+1  A: 

You may want to look into WebFlow (Spring WebFlow) in Grails. I find it helpful in wizard like or shopping cart like applications where you want to hold on to the data between a group of pages (ie: Page 1, Page 2... Page 4) and then at the end submit the data somewhere etc.

tegbains