2 Replies Latest reply on Feb 23, 2010 8:07 AM by Markos Fragkakis

    Action on enter key

    Markos Fragkakis Newbie



      I have a datatable with <h:inputText> as search fields. I want a method on the backing bean to be invoked when ENTER key is pressed, as well as the DataTable to be re-rendered.

      My approach so far only works in IE 6, and 7, not in FF. This is the inputText:


           id="applicantNameFilterValue" onkeypress="submitByEnter(event)">

      and this is the Javascript method I am invoking:


      function submitByEnter(e){
                // alert("Enter was pressed");


      As you can see, the Javascript method clicks on the button refresh, which exists on the page:


      <a4j:commandButton value="Refresh" id="refreshButton"
           reRender="table, scroller">


      The refreshData method does not return anything. As said before, this only works in IE 6 and IE 7.


      Does anyone know why it does not work in FF?


      An alternative I was consideting was HotKey, which can indeed catch the event of ENTER, but I think it can only invoke Javascript.

      Is the proper way to do this via RichFaces or plain JSF?