tags:

views:

673

answers:

1

i have a xhtml popup page which has two buttons.The two buttons have actionListener methods in their backing beans. When the user clicks enter how can i ensure that the first buttons actionListener method gets called.

A: 

Several frameworks provide a tag to allow for this, for example <s:defaultAction/> from Jboss Seam. It is just adds a piece of javascript to your page that listens for the enter key.

If you aren't using Seam or similar, then add the javascript yourself - for example something like this

Damo