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.

user-defined property type gotcha’s

When you create a user-defined property type there are two things to keep in mind.

  1. The user-defined property should be transient.
  2. The user-defined property must have a data-type defined or the item that contains this property will not be displayable in the ACC.

Here is an example of a user-defined property type.

<item-descriptor name="foo" display-property="name" display-name="Foo">
  
 <property name="bar" property-type="com.betweengo.Bar" data-type="string"/>
 
 <table name="foo" type="primary" id-column-names="id">
  <property name="id" data-type="string"/>
  <property name="name" column-names="name" data-type="string"/>
 </table>
 
</item-descriptor>

To learn more, User-Defined Property Types. Note that in the ATG documentation the example for the user-defined property does not define a data-type. This is probably a documentation bug.