Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Retain Scroll Position  RSS feed

 
m yasmin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
Is there a way to retain the Scroll Position in JSF? I have a page that uses both standard JSF and Tomahawk tags. Everytime the page reloads it jumps to the top.

I used JavaScript as a work around. However, I am wondering if there is a better solution.

Thanks,
Yasmin
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not without using a client side language such as Javascript. It is as far the only language which can tell you something about the current scroll position and is able to change it.

JSF runs entirely at the server side and just produces a bunch of HTML. It can't to anything for you here.
 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[edit] Got server error? Anyway, this post got doubleposted. Removed now.
 
m yasmin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks a bunch. I thought I would ask just in case you guys know a better way.

Yasmin

 
Bauke Scholtz
Ranch Hand
Posts: 2458
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This message was edited 2 times. Last update was at Today 15:26:12 by Bauke Scholtz
Funny, I edited it only 1 time. The forum software is bugging.
 
m yasmin
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mr.gluck,
I just put focus on the buttons of the page so the page does not jump to the top when a particular button is clicked.

<snippet>
onclick="document.getElementById['element'].focus();"
</snippet>

Hope it helps.
Yasmin
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!