I have a javascript function to run h: or a4j: commanButton. When javascript function is called, action button runs action but after that page is not redirected.
I am using Seam 2.2 and RichFaces 3.3.3
What is the problem here? Thanks.
function submitForm(){
document.getElementById('myForm:save').click();
// does not redirect.
//document.getElementById('myForm').submit();
}
Even if I use submit() page is not redirected.
Form:
<h:form id="myForm">
//some fields
<h:commandButton id="save" value="Save"
action="#{personHome.persist}" />
</h:form>
To the point, the following should work for
<h:commandButton>:and when the button is the first button of the form in question:
You only need to ensure that the generated client ID is exactly the same as the ID which you’re specifying in
getElementById(). If the<h:form>is by itself nested in anotherUINamingContainercomponent, then the ID will be prepended with its ID. Rightclick page in browser and View Source to be sure.As to the concrete problem, perhaps you’ve attached this function to another button which in turn also submits some form by itself which will result in a race condition of two requests. You should then
return false;from or after the function to block the caller’s default action. E.g.with