In my application, I am adding form data in database on click of submit button.But the problem is, when user refreshes the page, the data added one more time into the database and so on...
What can be the solution for this, please some body give me good link/solution for this problem...
Thanks a lot.
Code :
<h:commandButton value="Submit" action="#{co.createAction()}" />
public String createAction() {
if (login.registerUser().equals("success")) {
return "index?faces-redirect=true";
} else {
return "failure";
}
}
public String registerUser() {
if (serv.createRegUser(reg)) {
return "success";
} else {
return "failed";
}
}
public boolean createRegUser(Registration reg) {
try {
initJpa();
regJpa.create(reg);
return true;
} catch(Exception e) {
e.printStackTrace();
return false;
}
}