I have to say that your question looks like a discussion between two people, but I will try to give an answer. I suppose you have p:commandButton to submit the form.
First add the JavaScript function:
<script type="text/javascript"> function handleResponse(xhr, status, args) { if (args.validationFailed) { window.scrollTo(0, 0); } } </script>
validationFailed is a callback parameter that PrimeFaces implicitly adds if validation fails.
Now commandButton :
<p:commandButton value="Submit" actionListener="#{myBean.submit}" oncomplete="handleResponse(xhr, status, args)"/>
This will call the JavaScript function after the completion of the AJAX request.
This is as far as I can guess, you did not provide a lot of information. Adapt this code to your needs.
source share