This is not specific to JSF. This is specific to HTML. When you let JSF generate a onchange="submit()"
attribute on the generated HTML input/select element, you're basically instructing the HTML input/select element to invoke the submit
function of the parent HTML <form>
element. This will trigger a full synchronous request which causes a full page reload. The default behavior is that the top of the page will be shown, exactly like as when you open the page by a normal link or performs a refresh.
If you want to perform an asynchronous submit, just throw in some ajax. JSF 2.x has builtin ajax support via <f:ajax>
tag.
So, instead of
<h:selectOneMenu ... onchange="submit()">
...
</h:selectOneMenu>
do
<h:selectOneMenu ...>
...
<f:ajax />
</h:selectOneMenu>
In case you intend to update a specific component elsewhere in the same view, specify its absolute or relative client ID in the render
attribute.
<h:selectOneMenu ...>
...
<f:ajax render="results" />
</h:selectOneMenu>
<h:panelGroup id="results">
...
</h:panelGroup>
See also: