Showing posts with label Scrollpostion after error message in ADF. Show all posts
Showing posts with label Scrollpostion after error message in ADF. Show all posts

Monday, February 24, 2020

Keep Scroll Position in ADF page/jsff


Requirement
usually we have long form in ADF jsff or jspx with many input fields tables etc on same page .Since fields are more we get vertical scroll bar .Now when user fill in all information on the page and scrolls down to click submit.If there are any errors in fields we show error message using below snippet.

 FacesContext ctx = FacesContext.getCurrentInstance();
 FacesMessage fm = new FacesMessage(FacesMessage.SEVERITY_ERROR, "Error .", "Please correct email address and confirm email address");
        ctx.addMessage(null,fm);








Now when we click OK page goes to top and scroll position is not maintained.


Solution :

just use an actionListener on submit button and the attribute partialSubmit="true" on the button or link.
due to this when click on submit  a partial submit will be executed instead of a full page reload.
In this case you would need to programmatically refresh components you want to refresh on click of submit  using   addPartialTarget(bindingofcomponent) in Java or the attribute partialTriggers="idofcomponent" on the components which should update because of that partial submit of submit button