4 Replies Latest reply on May 11, 2007 11:29 AM by pmuir

    submit on enter

    ypasmk

      hi all I have an xhtml page that has an <h:form> element and in it I have alot of <h:commandButtons> and <h:commandLinks> and I have two <h:inputText values so the user can enter his user/pass to login..the problem is that if he press enters when finished with his pass the page is reloaded..In order to login he must click the login commandLink...is there another way to bind the users enter in password field to call the login function without using another <h:form> for this

        • 1. Re: submit on enter
          tony.herstell1

          I could be wrong but I think seam finds the "nearest" command button and automagically presses that when you hit enter!
          Shuffle the button round so that "submit" is nearest the password field.
          Works for me!
          (I have asked for a way of saying which I want the default button to be on a page with no luck so far so ask for that and it might get considered.

          Basically set breakpoints on all handlers for you buttons/links and see which is being called when the user presses enter !

          • 2. Re: submit on enter
            ypasmk

            Well after some searching I found this...dont know if it's working but I'll try it right now

            http://www.jsftutorials.net/defaultActionTag.html
            


            • 3. Re: submit on enter
              cwash

               


              I could be wrong but I think seam finds the "nearest" command button and automagically presses that when you hit enter!
              Shuffle the button round so that "submit" is nearest the password field.
              Works for me!


              I think you're right in that this is how JSF determines which command button to turn into a type="submit" (which will respond to the enter button keypress). If you want it to appear second, this is something you can do easily with a style change.

              I'm really surprised no one thought that through when designing JSF. It's pretty basic form stuff...

              • 4. Re: submit on enter
                pmuir

                Yes, this is a bug in JSF. We'll have to make sure it goes into the next version. You could suggest to Ajax4jsf they have a version of this tag in their toolkit, it is, IMO, the right way to do it, and seems like a good fit for a4j.