Can h:inputText invoke a method inside managed bean when I press the return/enter key

前端 未结 6 1370
孤城傲影
孤城傲影 2021-02-03 14:54

So I have an inputText that has its value hook to myBean.text, I want that if I click enter/return key, the inputText will invoke a method inside

6条回答
  •  再見小時候
    2021-02-03 15:23

    As per your question history, I know that you're using JSF 2.0, so here's a JSF 2.0 targeted answer: use which listens on a change event and use keypress event to invoke it when the enter key is pressed (keycode 13).

    
        
    
    

    The #{bean.listener} should point to a method like

    public void listener(AjaxBehaviorEvent event) {
        // ...
    }
    

提交回复
热议问题