Internet Explorer form does not invoke ATG handler

In Internet Explorer if you have a form that has only a single line text input and if you press Enter to submit the form instead of pressing the submit button then the ATG handler for this form will not be invoked. Instead the form will act like a regular HTML form.

To get around this problem on Internet Explorer one must explicitly call the handler using a hidden input tag.

Here is an example of a simple form that illustrates this problem. The action of this form is to go to wrong.jhtml but if the ATG handler is invoked then the request is redirected to right.jhtml.

<form name="test" action="wrong.jhtml" method="get">
  Name: <input type="text" bean="/TestFormHandler.name">
  <p><input type="submit" bean="/TestFormHandler.submit">
</form>

Here is a screenshot of this form.

test form with only one input field

When I press Enter I go to the wrong page, i.e. wrong.jhtml, because the handler is not invoked.

example of a form working incorrectly

When I press the Submit button I go to the right page, i.e. right.jhtml, because the handler is invoked.

example of a form working correctly

To fix this I add this line within the form of testForm.jhtml.

  <input type="hidden" bean="/TestFormHandler.submit">

I also add this getter, which does nothing and may not be necessary for later versions of ATG, in the form handler.

  public String getSubmit() { return null; }

After doing this when I press Enter I go to the right page.

Note that with a form that has more than one input field this is not a problem.

test form with two input fields

The source for this example can be downloaded here.

2 thoughts on “Internet Explorer form does not invoke ATG handler

  1. These points put forward by you are simply awesome.In fact two of the solutions you have mentioned were implemented by us.Unfortunately we spent 2 full days to solve these errors.We should have gone through this link before we spent those 2 days :).I hope people who search for similar problems would save lots of time from now.

Leave a Reply

Your email address will not be published. Required fields are marked *