ConcurrentModificationException when using the CustomField add-on

Hi all,

I installed the CustomField add-on (version 0.9.0) and followed the examples from the source code at

It all works fine until I call setVisibleItemProperties() on my main form. If the list of visible items contains my CustomField, I get the following exception:

	at java.util.LinkedList$ListItr.checkForComodification(
	at java.util.LinkedList$
	at com.vaadin.ui.CssLayout.paintContent(
	at com.vaadin.ui.AbstractComponent.paint(
	at com.vaadin.ui.Form.paintContent(
	at com.vaadin.ui.AbstractComponent.paint(
	at com.vaadin.ui.CssLayout.paintContent(
	at com.vaadin.ui.AbstractComponent.paint(
	at com.vaadin.ui.CssLayout.paintContent(
	at com.vaadin.ui.AbstractComponent.paint(
	at com.vaadin.ui.Panel.paintContent(
	at com.vaadin.ui.Window.paintContent(
	at com.vaadin.ui.AbstractComponent.paint(
	at com.vaadin.ui.Window.paintContent(
	at com.vaadin.ui.AbstractComponent.paint(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.writeUidlResponce(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.paintAfterVariableChanges(
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(
	at javax.servlet.http.HttpServlet.service(
	at org.mortbay.jetty.servlet.ServletHolder.handle(
	at org.mortbay.jetty.servlet.ServletHandler.handle(
	at org.mortbay.jetty.servlet.SessionHandler.handle(
	at org.mortbay.jetty.handler.ContextHandler.handle(
	at org.mortbay.jetty.webapp.WebAppContext.handle(
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(
	at org.mortbay.jetty.handler.HandlerCollection.handle(
	at org.mortbay.jetty.handler.HandlerWrapper.handle(
	at org.mortbay.jetty.Server.handle(
	at org.mortbay.jetty.HttpConnection.handleRequest(
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(
	at org.mortbay.jetty.HttpParser.parseNext(
	at org.mortbay.jetty.HttpParser.parseAvailable(
	at org.mortbay.jetty.HttpConnection.handle(
	at org.mortbay.thread.QueuedThreadPool$

If I remove the CustomField property, everything shows up. However, since it’s not part of the visible item properties, calling “discard()” on my main form doesn’t call “discard()” on my CustomField.

Does anybody have an idea on what’s going on here?



Where/when are you calling setVisibleItemProperties()?

I assume you are trying to do this with the EmbeddedForm in the example, nesting the sub-form fields directly in the top-level form layout. There are some limitations and complications in the sample EmbeddedForm class with respect to how fields are added to and removed from the top-level form, so I would not be surprised if this is the cause.

I tried different approaches and places to call setVisibleItemProperties().

  1. Passing a list of visible item properties to the setItemDataSource() method.
  2. Calling setItemDataSource() first, then setVisibleItemProperties().
  3. Calling setVisibleItemProperties() first, then setItemDataSource().

Yes you’re assumption is correct in regards to the EmbeddedForm and how I use it. I literally replicated what I found in the source code mentioned in my previous post.

I’ll investigate further and if I can’t solve it, might have to use a different approach. Do you have any suggestions on an alternative to the CustomField add-on?

The complications are related to how the Form adds and removes its fields to its layout, and how it interacts with EmbeddedForm. I have not looked into it for a long time, but I do remember it was tricky.

A cleaner alternative would be to have the Item expose also the nested contents directly as item Properties. With Vaadin 6.6.0.pre1 and later, you can add nested bean properties to a Bean[Item]
Container or a BeanItem/PropertySetItem - e.g. myPersonContainer.addNestedContainerProperty("address.street") or myItem.addItemProperty(new NestedMethodProperty(myItem.getBean(), "address.street"));

Thanks, I read about the addNestedContainerProperty() method earlier this morning. I’m trying to upgrade right now, but having some troubles with compiling my widgetsets with GWT 2.3.0. I’ll post that in a separate thread if I can’t resolve it ;).