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

前端 未结 4 1848
佛祖请我去吃肉
佛祖请我去吃肉 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:40

    If the previous answer does not work, you can create a js function, for example:

    function focusField(id){
     $(id).focus();
    }
    

    Then in your bean, assuming u want set focus on field "input4" , it represents ID not Widgetvar

    RequestContext.getCurrentInstance().execute("focusField('#input4');");
    

提交回复
热议问题