You could add a javascript function that catches the key up event and
add it to each control passing the ID of the
commandlink/commandbutton, and force the click event of that
link/button.

Example (didn't test it, but should work for IE and firefox):
<t:outputText onkeyup="checkDefaultSubmit(event, 'mysubmit')" />
<t:commandLink id="mysubmit" forceId="true" value="submit" />

Javascript:
function checkDefaultSubmit(event, controlId)
{
  if (event.keycode != 13) return
  var fireOnThis = document.getElementById(controlId)
  if (document.createEvent)
  {
    var evObj = document.createEvent('MouseEvents')
    evObj.initEvent( 'click', true, false )
    fireOnThis.dispatchEvent(evObj)
  }
  else if (document.createEventObject)
  {
    fireOnThis.fireEvent('onclick')
  }
}



On 4/21/06, Lindholm, Greg <[EMAIL PROTECTED]> wrote:
> Is there anything in MyFaces/Tomahawk for specifing the
> default action to take when the user presses Enter key
> in a form?
>
> How are people dealing with this?
>
> I know there is a j4j:defaultAction but it doesn't work
> for Firefox.
> (http://www.jsftutorials.net/defaultActionTag.html)
> Has anyone built a version that works with Firefox?
>
> Greg
>
>

Reply via email to