Set Focus for Primefaces Component in Bean with WidgetVar with RequestContex Execute

前端 未结 4 1885
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-29 04:14

Is there a way to set my component focus after an function call to an other component with Primefaces RequestContex?

i tried:

RequestContex.getCurrentIns         


        
4条回答
  •  灰色年华
    2021-01-29 04:42

    Using PrimeFaces 6.1, for reasons unknown, I was unable to get the primefaces p:focus to work. So, I just implemented an onload JQuery function to set focus to a p:commandButton. For the onload call, put the jQuery nested function below in the 'body'. This is to be sure to override any other primefaces onload functions.

    
    

    PrimeFaces creates widgetVar components for all of the primefaces components. Some features are available though the widgetVar such as disable or enable. But, I had to use the getJQ() function to obtain the jQuery object and used that object to set focus on the command button.

提交回复
热议问题