Situation:
- imagine one form for adding items to the database
- user correctly fill the form and using Save button (h:commandButton) save the item into the DTB
- lifecycle of saved object is finished and form is cleared
- after that, user (don’t ask me why:-)) press the refresh button of the browser
- and result is => there are two almost the same items in the DTB (different just in create time)
How can I prevent that behaviour?
Two ways:
Use ajax to execute the action (this doesn’t generate browser history).
Send a redirect after post (known as POST-Redirect-GET pattern).