-3

How to stop the JSF form from moving to the top of the screen after an AJAX call

This question has been asked but the answers provided are either outdated or none JSF specific. Is there any easy way in JSF ( perhaps a missing technicality in using JSF ) that will prevent the JSF form from returning to the top of the page after an AJAX update?

This is the best answer I have so far:

stop scrolling to top after AJAX request

But I can't seem to get a straight answer out of them on how to apply this to my JSF. I am using Redhat JBoss Developer Studio and the latest JSF 2.0 ( I think it'll do 2.2, the option is there, haven't tried it yet). Also, making use of RichFaces and Primefaces.

The best answer so far refers to telling JavaScript to return a 'false' but how to do this from within JSF or without too much trouble trying to override it's internal functions:

You need to replace href="#tabs-1" for each li with 
href="javascript:void(0);" or write a function that would do 
that for you or href="" and add 'return false;' at the end of 
your onclick function . #tabs-1 creates an html anchor that pushes
the page to the top.

You come highly recommended on the forms, I am hoping you might know all about this.

Thanks,

Perry

Community
  • 1
  • 1
Perry
  • 35
  • 3
  • This is not the default behavior of any JSF ajax component. You'd best update the question to include the problematic code in MCVE flavor. – BalusC Mar 23 '15 at 17:03
  • Check this http://stackoverflow.com/questions/28629407/disable-page-jumping-to-the-top-after-commandbutton-is-clicked – Kukeltje Mar 23 '15 at 18:37

1 Answers1

0

Sounds like you're reloading the whole page. Perhaps you have missed the update attribute on a primefaces ajax element. This will update only the indcluded element when the ajax is complete.

Please post your code so we can be sure.

Mark W
  • 5,824
  • 15
  • 59
  • 97