So i have a JSF Application. If i submit a form, it gets resubmitted when i refresh the page. and of course i don't want that.
Index.xhtml:
[...]
<h:form >
<h:outputText value="Form"/><br/>
<h:inputText label="first" value="#{example.newExample.firstWord}" autocomplete="off"></h:inputText>
<h:commandButton value="click" actionListener="#{example.NewExample()}">
</h:commandButton>
</h:form>
[...]
The method that gets runned:
public void NewExample(){
pfDB.InsertNewExample(NewExample);
NewExample.setFirstWord(null);
NewExample.setSecondWord(null);
}
So everytime i refresh index.xhtml after i submitted the form, NewExample() get runned.
It was indeed the resubmitting off the form that was the problem. But the browser(opera) didn't showed an alert.
I fixed it by adding
FacesContext.getCurrentInstance().getExternalContext().redirect("index.xhtml");
in my function