views:

1678

answers:

2

A HTML page is created using JSF and facelets (xhtml). There are 2 h:forms that goes to different places. The user enters data on one form and presses the "Enter" key. Here is where it gets tricky. On IE 6 and above, either the forms action gets submitted (which usually points to the page you are on) which then just reloads the page, or the first h:commandbutton/link that is on the page. Its totally random, but its consistant on that page.

Here is what I have tried, I tried placing the components that have to be submitted in their own form...it works but not everywhere. Then I tried creating a hidden input with the id of the button, it works quite effectively, but it is then bypassed somehow by IE trying to invoke the first button on the page. I tried a product called j4j that supposedly creates a default action, but it doesn't work, outputting the tag itself in the rendered HTML. When it does work, it creates javascript they looks for key 13, and then invokes oamsubmit(...., which incidently I tried also with varying degrees of success.

Is there a solution out there that work permanently? Have I missed something or am I not understanding JSF?

A: 

Very similar question to this

This isn't a JSF problem as much as a standard HTML/Javascript issue.

Damo
Could you elaborate? Since its JSF creating the form tag with the action pointing to the same page, and the extensive javascript to handle the submit of a form.
Gerrie
I mean that it's the same issue as getting non-JSF Javascript to click a submit button.
Damo
+1  A: 

This is how I solved it in JSF (just add this to your h:form)

<h:inputText id="StackOverflow1205114" value="Fix IE bug" style="{display:none}" /> 

which will create output to this:

<input id="_id3:StackOverflow1205114" type="text" name="_id3:StackOverflow1205114" value="Fix IE bug" style="{display:none}" />
JeffJak
I have ran into this multiple times.
JeffJak
What is the bug that this fixes, and how?
Thorbjørn Ravn Andersen
Getting the enter key to work on form in IE
JeffJak