3 Replies Latest reply on Aug 25, 2008 4:06 PM by lance stine

    IE submit bypasses action and navigation bug

    lance stine Newbie

      I hope someone has seen this before. It's not really a seam issue but it prevents seam from working.


      I have a basic form and a commandButton boiled down to this:


      <h:form id="agencyForm">
      <h:inputText id="agencyName" value="#{agencyHome.instance.agencyName}"/>
      <h:commandButton id="save"
          value="Submit Agency Information"
          action="#{agencyHome.persist}"
          onclick="return confirm('Are you sure that you would like to add this Agency record?');"/>
      </h:form>



      Page navaigation is seam does a redirect based on the outcome of the persist method:
      <navigation from-action="#{agencyHome.persist}">
             <end-conversation/>
             <redirect view-id="/dre/agency/manager.xhtml"/>
      </navigation>


      Just when things look too easy, IE can't seem to submit the form right. If you hit enter after entering data into the inputText then IE will not execute the agencyHome.persit method and the page navigation won't occur. A postback will happen and the data in agencyHome.instance.agencyName will be updated. If you click the button then everything works perfectly.


      Are there any ways around this? Am I doing something wrong? IE is a requirement of this project.


      Thank you



        • 1. Re: IE submit bypasses action and navigation bug
          Tomaz Cerar Master

          Hi,


          we have same problem. But problem occurs only in IE. If you hit enter it does not work. But if you click on button everything goes well. I am fixing that by adding javascript that checks if enter was pressed and then clicks on button..


          If anyone knows better solution I would also like to know...


          cheers,
          tomaz

          • 2. Re: IE submit bypasses action and navigation bug
            Daniel Roth Apprentice

            In some cases, you could add a valueChangeListener to the inputText.

            • 3. Re: IE submit bypasses action and navigation bug
              lance stine Newbie

              I finally pin-pointed the bug and have a decent hack.


              Strangely enough, if the form in IE only has one input text field, then it will not fire an onclick event and will somehow submit the form wrong to seam. If I had any spare time, I would figure out what exactly it is doing wrong with the form submission.


              In any case, the easiest hack is to add another invisible text field to the form. IE is then happy enough to fire onclick events and submit correctly.


              Try out this HTML to see this bug in action:


              <form id="gohsAgency" name="gohsAgency" method="post" action="http://www.google.com"  enctype="application/x-www-form-urlencoded">
              <input id="gohsAgency:agencyName" type="text" name="gohsAgency:agencyName" value="hoho" maxlength="50" size="50" />
              <input id="submit" type="submit" name="submit" value="submit with bug" onClick="return confirm('Are you sure that you would like to edit this Agency record?')" />
              </form>


              Here is a form working as expected:


              <form id="gohsAgency" name="gohsAgency" method="post" action="http://www.google.com" enctype="application/x-www-form-urlencoded">
              <input id="g" type="text" name="g" value="hoho" maxlength="50" size="50" />
              <input id="p" type="password" name="p" value="" />
              <input id="submit" type="submit" name="submit" value="submit no bug" onClick="return confirm('Are you sure that you would like to edit this Agency record?')" />
              </form>


              Making it work right with an invisible text input:


              <form id="f" method="post" action="http://www.google.com" enctype="application/x-www-form-urlencoded">
              <input id="g" type="text" name="g" value="hoho" maxlength="50" size="50" />
              <input id="h" type="text" name="h" value="wow what a bug, this field has to be here" size="1" style="visibility: hidden"/>
              <input id="submit" type="submit" name="submit" value="submit with hack" onClick="return confirm('Are you sure that you would like to edit this Agency record?')" />
              </form>


              This is unbelievable. I never thought that I would be debugging internet explorer.