3

I have a inputTextarea that I refresh using PrimeFaces' AJAX poll.

When the inputTextarea is refreshed, a lot of new text will be displayed. However, it will always jump to the first line after refresh. If the user wants to scroll down and the poll/refresh happens, it will jump to the top anyway.

Is there anything I can do to prevent the jumping to the top (or better: prevent jumping at all)? If not, can I make the inputTextarea stay on the bottom at least? (Since the new lines will be appended to the bottom.)

I'm using JSF 2 (MyFaces), Tomahawk and PrimeFaces.

ordnungswidrig
  • 3,140
  • 1
  • 18
  • 29
geeehhdaa
  • 822
  • 5
  • 17
  • 30

1 Answers1

4

Use JavaScript. Include this script below the <h:inputTextarea> in the portion which is been updated by <p:poll> or in a function when the component supports oncomplete (not sure as I don't have recent PF documentation).

var textarea = document.getElementById("clientIdOfTheTextarea");
textarea.scrollTop = textarea.scrollHeight; // Scrolls to bottom.
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555