Richfaces, IE-“runtime error” and nested forms

When developing a webapp with Richfaces, you will sometimes encounter a javascript “runtime error”. This error will only occur in MS Internet Explorer (seen at version 6/7).

I struggled and but then i found the reason and the solution. In Richfaces 3.3.2 CR1 there is some JS code in form.js, which tries to get all elements from the surrounding form. Like this

//..
var field = form.elements[fields[i]]
//..

This seems to fail only in Internet Explorer.
But why? I don’t know for sure, but it only occurs when you nest forms. Nesting of forms is invalid HTML, so it is not a bug in Richfaces. Check your UI structure instead.

<!--Not valid / never do this-->
<h:form>
  <h:form>
   <!--stuff-->
  </h:form>
</h:form>

Remember: NEVER ever nest forms into form.

Advertisements

One thought on “Richfaces, IE-“runtime error” and nested forms

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s