I have a page where a user enters data and hits a "save" button. The data gets saved to the db, and I want the page to refrsh itself to reflect the new data in the db. I am using a managed bean, how do i get the page to refresh on its own?
There are two options which come to my mind:
ad 1)
Define a page to which you'll navigate to after hitting "save".
For doing that, your action for actually saving the data to DB will go into the method defined as an actionListener
or, if you want to make your next page depending on the outcome of the saving process, as action
.
Navigation rules will be defined in faces-config.xml If no navigation rule matches a given action, the current page will be redisplayed (although from the experience i made this refresh is different to a common HTML refresh).
ad 2)
If you've some lists or a data table on the same page set to a model in your bean, changes will automatically be displayed except you're using the immediate
keyword set to true on your save button.
Additionally you might consider a panel with a content of your choice which has the rendered
property set to a boolean in your bean, which will be triggered within the saving process and therefore let the content be displayed only after hitting save.