Calling of actionListener on commandButton on refresh

Hi,

I am using one command button. On click , it is adding one record in tabel. It is creating some problem for me. It is working properly means it is adding proper data. But it went wrong, after adding a new row in table, if i do a refresh on that page it calls the actionListener method again. I can handle the duplicate data in the method. But i dont know why he is calling the actionListener on refresh of page ,

My command button is

<h:commandButton value="Add In Table" actionListener="#{User.addInTable}" />

I want to use onClick tag. But it just call Java Script function. i want ot call the addInTable() written in User Bean.

Thanks in Advance

[698 byte] By [SujayPatila] at [2007-11-27 3:58:41]
# 1
R u using scope as Session?sriaknth
srikanthga at 2007-7-12 9:03:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 2

This is because you're resubmitting a POST request by invoking a refresh. Generally the user client (at least, Internet Explorer and FireFox) should warn you about this and ask for confirmation to resubmit the POST. Don't you get this warning?

If you want to disable rePOSTing when refreshing the window, consider implementing a Post-Redirect-Get pattern. At the bottom of this article you can find an example: http://balusc.xs4all.nl/srv/dev-jep-prg.html

BalusCa at 2007-7-12 9:03:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...
# 3
Thanks,It worked. I tried by implementing the Post-Redirect-Get pattern.
SujayPatila at 2007-7-12 9:03:08 > top of Java-index,Enterprise & Remote Computing,Web Tier APIs...