Scroll p:messages into view when it is updated and (error) messages are present

前端 未结 4 1251
暖寄归人
暖寄归人 2021-01-05 18:58

I am working with PrimeFaces messages, I want my whole page to scroll to top when p:messages is rendered.

4条回答
  •  孤街浪徒
    2021-01-05 19:47

    Assign an ID to your p:message component

    
    

    Then, in your backing bean call RequestContext.scrollTo method:

    • in PrimeFaces >= 6.0:

      PrimeFaces.current().scrollTo("myMessage")
      
    • in Primefaces < 6.0:

      RequestContext context = RequestContext.getCurrentInstance();
      context.scrollTo("myMessage");
      

      which is deprecated in PrimeFaces 6.0

提交回复
热议问题