4 Replies Latest reply on Jul 22, 2009 10:55 AM by oneworld95

    Default form button?

    oneworld95

      Hi. Is there a way to declare a button to be the default for a form? In other words, if user hits the Enter key in a field, that button's action will be performed. I've looked at all the properties of an <a4j:commandButton> and can't find a way to set it to be the default form button. Thanks.

        • 1. Re: Default form button?
          israel.bgf

          Are you using Seam? If yes, maybe a s:defaultAction is what you are looking for. Check the reference for more details.

          • 2. Re: Default form button?
            oneworld95

            Thanks, Israel. Yes, I'm building using Seam. I knew I'd seen it somewhere but couldn't remember where. s:defaultAction should do the trick :)

            • 3. Re: Default form button?
              magiccreative

              s:defaultAction works only on h:commandButton if I remember correctly. I had a situation where I wanted my s:commandLink as default action but it didnt work, so I used the a4j:hotKey and specified in brackets which combination should be used. Works much better in "rich" enviroment because you can have buttons in modal panels, divs , regions and what not and still call the right one with a shortcut (ofc. not enter)

              • 4. Re: Default form button?
                oneworld95

                Very interesting. Thanks, magiccreative. I've got the s:defaultAction in an a4j:commandButton, so I'm guessing it won't work there. I'll look into the a4j:hotKey and see how to use that. Thanks a lot for your help.