adgfs
adgfs

Reputation: 423

Submit button + GWT History

A good design solution when a form is submitted, what should be the behavior of "back" and then "forward" browser button. Similar question is what should happen when a user logout an application the then click "forward" browser button?

I will be glad to hear some scenarios for the mentioned situations.

Thanks.

Edit - should be good to share and my point of view :-)

My personal opinion is after logout the user should be not able to enter the application without go through the login page. For the submit scenario - after submitted and back browser button , the user should be able to return to the form but with NO containing data.

Upvotes: 0

Views: 363

Answers (2)

gatkin
gatkin

Reputation: 1912

One common pattern is Post/Redirect/Get. Under that pattern, the result of the post is a bookmarkable (and back/forward navigable) page. The Back button has one of it usual meanings of "I didn't mean to go here, take me back where I was" like hitting ESC in most Windows dialogs, and the Forward button means "I didn't mean to hit the back button, I wanted that page after all." This pattern isn't going to work for everyone; it makes the most sense when each page (including the response to a form submit) represents some conceptual entity that you'd want to bookmark.

As for the logout scenario, most apps check whether you're logged in no matter what page is specified in the URL, and redirect to the login form if you're not logged in. (You don't have to code that on every page; the check is usually a Valve or something.) A nice feature is to remember where the user was trying to go and take them there upon sucessful login.

Your question is more about design than technology, so GWT doesn't really change the picture, except to note that the GWT history mechanism is intended to mimic the behavior of static pages connected by links, which the post/redirect/get pattern does also.

Upvotes: 1

salman.mirghasemi
salman.mirghasemi

Reputation: 1059

It is very common to use state machines to keep the user(session) and request state. If you have such a state machine then you know that user is trying a wrong transition. Depending on the user state and the wrong transition you can forward the user to a page. For example if the user tries to go to a page which needs to be logged in but she/he has already logged out, you can send her/him to a login page but you can provide user name and only ask for the password.

To add this functionality you can write your own code by hard-coding the state machine in your code or you can use one of the available libraries. For example, Spring Web Flow provides this functionality for Spring framework.

Upvotes: 1

Related Questions