2
votes

EDIT: More detail here. Basically if you

1. open a tab1 to url1 (GET request which may save url in session)
2. open a tab2 in another url2 (GET request which save url in session overwriting 1)
3. go back to tab1, and click add project which issues GET request to get post form
4. when posting now, it will go back to tab2 incorrectly when it should go back to tab1 since that is where we choose "create new issue" link from.

This behavior pretty much is very confusing to the user. As web developers, we want to be able to add an add project button on any page in our application, but that results in the above type of bugs consistently which is very annoying.

The main question of this post is WHAT are others doing for tab/conversation state? Read through the example below as well.

We have been porting from seam....while the conversations where semi nice, we almost really wanted tab state. The more we analyzed this, the more we understood why no tab state exists.

  1. We could create a tabid=xxxx where xxx is a guid, but in playframework, when would you time that out. If the network went down, you would never know that it times out. tabid would then tie back to a cookie with the name xxxx for that domain so you have tab state.

  2. You could put the tabids in the session cookie every time so that you could eventually time out the tabs....not a bad idea really. would be nice if play already had something like this. If a user had stuff open to long, it would end the tab state...would need to save timestamps of last request from that tab which had the tabid param in it.

  3. For now, we are going with ajax popping of forms so if someone is adding a ticket, and they pulldown the projects menu and choose new project, we stay on the page and ajax popup a form....not sure how this will work.

Our main goal is really we always want to go back to the url that the user came from and be able to add edit/add buttons to any page and not worry about getting back to the page the user came from....the only way I can think of doing that is ajax popping up BUT that has a really big disadvantage of NO referencable urls.

EXAMPLE: We have edit project, ideally a user can go straight to the url of the edit project url which has the project name in the url!!! but then we can't get back to the url they came from, OR we can do ajax form popup BUT then we can't have a nice url that can be passed around to view/edit the project(mostly view).

What are other people's thoughts on this? Which direction to take? We prefer not to have a read project page and edit project page and just have one edit project page that most people just read and sometimes edit.

thanks, Dean

4

4 Answers

1
votes

About the session cookie, you can set a max life time I don t really understand your project example. Why can't you go back to the project URL?

1
votes

I think the "correct" way to do this would be to include the Referrer header in the forms that should redirect back, somewhat like

<input type="hidden" name="redirect" value="#{request.headers.get("referrer").values.get(0)}"/>

Not completely sure about the template syntax (I've only used the Scala API and 2.0), but you should get the gist of it. For the record, the PHP equivalent should look like this:

<input type="hidden" name="redirect" value="<?php echo $_SERVER['HTTP_USER_AGENT'] ?>
0
votes

About the tabs, you should have a look at the play booking sample app. It is the same as the seam sample app and it demonstrates your use case. In short, tabs and states are managed client side.

0
votes

interesting, there is a specification on sessionStorage.setItem/getItem in javascript now and it seems to be per tab!!! I tested it in IE9, chrome and firefox...all work...still need to test IE7 and IE8 but nonetheless that led to another project which seems to work even in IE6 with a bit of a kludge maybe...

http://code.google.com/p/sessionstorage/

This is the best answer by far....true tab state...nice!!!

You can open two tabs in your browser and test this sessionStorage at this website

http://people.opera.com/shwetankd/external/demos/webstorage_demo2.htm