File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes JSF and the fly likes JSF keep page coordinate Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "JSF keep page coordinate" Watch "JSF keep page coordinate" New topic
Author

JSF keep page coordinate

Gabriel Beres
Ranch Hand

Joined: Sep 09, 2006
Posts: 61
Hi Again,

Is there way, to keep the page coordinates in JSF? I have a lengthy page, and it is very annoying, that when the user submits something, the page goes to the top.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 15960
    
  19

When you submit a request, the page that comes back could be totally different than the page that did the submitting, so the old "page coordinate" wouldn't be valid. Since the client doesn't know what the server may do, it doesn't even try.

There are 2 ways around this.

1. Use the HTML anchor tag. If you append a "#name" to the end of a URL (before the query part), that tells the browser to position the displayed page to the named "<a> element. This is hard to do in JSF, because JSF has mostly taken over the URL structure.

2. Use AJAX. If you use AJAX, you don't request a new page, just data that will be used to update the current page. So the browser doesn't lose track of where you were positioned. If you delete the "current position", the browser will simply reposition to someplace reasonably close.


Customer surveys are for companies who didn't pay proper attention to begin with.
Gabriel Beres
Ranch Hand

Joined: Sep 09, 2006
Posts: 61
Thanks, i will go with ajax.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: JSF keep page coordinate
 
Similar Threads
Creator 2 and Ajax4JSF
JSTL if statement does not work
Servlet created JSF bean
Finding which cell was clicked in a DataTable?
SCWCD Forum FAQ's....................