2 Replies Latest reply on Oct 30, 2008 8:14 AM by justinmbirch

    a4j:commandButton

    kdcosta

      hi

      i have a search page.
      There is a h:inputText and a a4j:commandButton in the same a4j:region.
      when we enter the some value in the inputtext and click button, its action method will be called.
      how can i make it work like this way, i.e i enter some value in input text and press enter key in the keyboard, and then the action is called and i get the result.

      hope u understood my question.
      plz hlep me.

      rgds

        • 1. Re: a4j:commandButton
          gizola


          One solution can be:

          you define javascript to the onkeypress event of the input box, and you check what key has been pressed in the input box.
          If it was the ENTER key, you call the onclick method of the ajax button.
          So you can post it with ENTER or witch clicking on the button. Both will work.

          Regards,

          Gizola

          PS: I'm not a big javascript warrior, so I don't know if you can catch the ENTER key with onkeypress, but try it, maybe onkeyup is better. But the logic should work.

          • 2. Re: a4j:commandButton
            justinmbirch

            See http://bytes.com/forum/thread92476.html

            explains how to capture key presses.

            Once you have a method to do that, just call document.getElementById( 'yourA4JCommandbutton').click();