Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to set the focus or navigate to the top of the JSP after submit ?

 
Vinodh Sa
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

Can anyone help me with how to make the webpage navigate to the top of the jsp, after submit method is called.

My problem is to make the webpage navigate to the top of the JSP after submit method is called. When i click oon submit method, my entire form is validated and based on the validations certain error messages are thrown. These messages/validation are thrown frm backing bean and not during JSF lifecycle validation phase, since we have many dependency validations, we cant go with JSF lifecycle validations.

Any suggestion(possibly without use of any javascript) would be helpful for me.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18028
47
Android Eclipse IDE Linux
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If you're submitting the entire View (non-AJAX), the entire webpage should be replaced, and by default that will be rendered from the top down the screen.

However, if you're doing an AJAX submit, only part of the display would be re-rendered and therefore the page would not scroll. To force it to scroll, you would have to use JavaScript, I'm afraid. I don't recall the JavaScript code that would be required, but you'd normally invoke it using an "oncomplete" attribute attached to the submit button or action.
 
Vinodh Sa
Ranch Hand
Posts: 55
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Tim Holloway wrote:If you're submitting the entire View (non-AJAX), the entire webpage should be replaced, and by default that will be rendered from the top down the screen.

However, if you're doing an AJAX submit, only part of the display would be re-rendered and therefore the page would not scroll. To force it to scroll, you would have to use JavaScript, I'm afraid. I don't recall the JavaScript code that would be required, but you'd normally invoke it using an "oncomplete" attribute attached to the submit button or action.


Hi Tim,
I m not using any AJAX method to submit. Its just a normal action method called from h:commandButton which is inside a h:form which is enclosed by a f:subview tag. And the view is in the layout page, so i m afraid i m not submitting the entire View. Since there is no need to submit the layout page.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic