Error adding two items to table

I have a table in editable mode. With the button ADD, the user can add a new item to the table:

	@Override
	public void nuovaTrattaClicked() {
		MyBean tt = new MyBean();
		tt.setDefaultValues();
        Object newItemId = myTable.addItem(tt); 
	}

The user now can edit new item’s fields. Pressing SAVE button:

	@Override
	public void salvaTrasfertaClicked() {
		if (!myTable.isValid()){
			getApplication().getMainWindow().showNotification("Error",Notification.TYPE_ERROR_MESSAGE);
			return;
		}
		for (Iterator<?> i =myTable.getItemIds().iterator(); i.hasNext();) {
			MyBean tt = (MyBean) i.next();
			try {
				MyBeanService.save(tt);
			} catch (DatiObbligatoriException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}	
		}			
		getApplication().getMainWindow().showNotification(app.getMessage("formstrutturale.updated"));
	}

the new record is correctly persisted. If now user press again ADD button to add the second item, he gets:

com.vaadin.event.ListenerMethod$MethodException
Cause: java.lang.NullPointerException
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:507)
	at com.vaadin.event.EventRouter.fireEvent(EventRouter.java:161)
	at com.vaadin.ui.AbstractComponent.fireEvent(AbstractComponent.java:1107)
	at com.vaadin.ui.Button.fireClick(Button.java:341)
	at com.vaadin.ui.Button.changeVariables(Button.java:177)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.handleVariables(AbstractCommunicationManager.java:1060)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:561)
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:260)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:438)
	at com.vaadin.incubator.spring.servlet.SpringApplicationServlet.service(SpringApplicationServlet.java:77)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
	at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
	at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(SessionFixationProtectionFilter.java:67)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:116)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.basicauth.BasicProcessingFilter.doFilterHttp(BasicProcessingFilter.java:174)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:378)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)
Caused by: java.lang.NullPointerException
	at com.vaadin.data.util.BeanItemContainer.getContainerProperty(BeanItemContainer.java:303)
	at com.vaadin.ui.AbstractSelect.getContainerProperty(AbstractSelect.java:719)
	at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1462)
	at com.vaadin.ui.Table.setCurrentPageFirstItemIndex(Table.java:1254)
	at com.vaadin.ui.Table.setCurrentPageFirstItemIndex(Table.java:1265)
	at com.vaadin.ui.Table.containerItemSetChange(Table.java:2782)
	at com.vaadin.data.util.BeanItemContainer.fireItemSetChange(BeanItemContainer.java:440)
	at com.vaadin.data.util.BeanItemContainer.filterAll(BeanItemContainer.java:478)
	at com.vaadin.data.util.BeanItemContainer.addItemAtInternalIndex(BeanItemContainer.java:167)
	at com.vaadin.data.util.BeanItemContainer.addItem(BeanItemContainer.java:291)
	at com.vaadin.data.util.BeanItemContainer.addItem(BeanItemContainer.java:39)
	at com.vaadin.ui.AbstractSelect.addItem(AbstractSelect.java:800)
	at com.vaadin.incubator.spring.ui.funzioni.FunNotaSpesa.nuovaTrattaClicked(FunNotaSpesa.java:532)
	at com.vaadin.incubator.spring.ui.NotaSpesaPulsantiera.buttonClick(NotaSpesaPulsantiera.java:127)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
	at java.lang.reflect.Method.invoke(Method.java:597)
	at com.vaadin.event.ListenerMethod.receiveEvent(ListenerMethod.java:487)
	... 63 more
java.lang.NullPointerException
	at com.vaadin.data.util.BeanItemContainer.getContainerProperty(BeanItemContainer.java:303)
	at com.vaadin.ui.AbstractSelect.getContainerProperty(AbstractSelect.java:719)
	at com.vaadin.ui.Table.refreshRenderedCells(Table.java:1462)
	at com.vaadin.ui.Table.getVisibleCells(Table.java:2380)
	at com.vaadin.ui.Table.paintContent(Table.java:2038)
	at com.vaadin.ui.AbstractComponent.paint(AbstractComponent.java:710)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.paintAfterVariableChanges(AbstractCommunicationManager.java:779)
	at com.vaadin.terminal.gwt.server.AbstractCommunicationManager.doHandleUidlRequest(AbstractCommunicationManager.java:592)
	at com.vaadin.terminal.gwt.server.CommunicationManager.handleUidlRequest(CommunicationManager.java:260)
	at com.vaadin.terminal.gwt.server.AbstractApplicationServlet.service(AbstractApplicationServlet.java:438)
	at com.vaadin.incubator.spring.servlet.SpringApplicationServlet.service(SpringApplicationServlet.java:77)
	at javax.servlet.http.HttpServlet.service(HttpServlet.java:820)
	at org.mortbay.jetty.servlet.ServletHolder.handle(ServletHolder.java:502)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1148)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:378)
	at org.springframework.security.intercept.web.FilterSecurityInterceptor.invoke(FilterSecurityInterceptor.java:109)
	at org.springframework.security.intercept.web.FilterSecurityInterceptor.doFilter(FilterSecurityInterceptor.java:83)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.SessionFixationProtectionFilter.doFilterHttp(SessionFixationProtectionFilter.java:67)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.ExceptionTranslationFilter.doFilterHttp(ExceptionTranslationFilter.java:101)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.providers.anonymous.AnonymousProcessingFilter.doFilterHttp(AnonymousProcessingFilter.java:105)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.rememberme.RememberMeProcessingFilter.doFilterHttp(RememberMeProcessingFilter.java:116)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.wrapper.SecurityContextHolderAwareRequestFilter.doFilterHttp(SecurityContextHolderAwareRequestFilter.java:91)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.basicauth.BasicProcessingFilter.doFilterHttp(BasicProcessingFilter.java:174)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.AbstractProcessingFilter.doFilterHttp(AbstractProcessingFilter.java:277)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.ui.logout.LogoutFilter.doFilterHttp(LogoutFilter.java:89)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.context.HttpSessionContextIntegrationFilter.doFilterHttp(HttpSessionContextIntegrationFilter.java:235)
	at org.springframework.security.ui.SpringSecurityFilter.doFilter(SpringSecurityFilter.java:53)
	at org.springframework.security.util.FilterChainProxy$VirtualFilterChain.doFilter(FilterChainProxy.java:390)
	at org.springframework.security.util.FilterChainProxy.doFilter(FilterChainProxy.java:175)
	at org.springframework.web.filter.DelegatingFilterProxy.invokeDelegate(DelegatingFilterProxy.java:236)
	at org.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:167)
	at org.mortbay.jetty.servlet.ServletHandler$CachedChain.doFilter(ServletHandler.java:1139)
	at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:378)
	at org.mortbay.jetty.security.SecurityHandler.handle(SecurityHandler.java:216)
	at org.mortbay.jetty.servlet.SessionHandler.handle(SessionHandler.java:181)
	at org.mortbay.jetty.handler.ContextHandler.handle(ContextHandler.java:765)
	at org.mortbay.jetty.webapp.WebAppContext.handle(WebAppContext.java:417)
	at org.mortbay.jetty.handler.ContextHandlerCollection.handle(ContextHandlerCollection.java:230)
	at org.mortbay.jetty.handler.HandlerCollection.handle(HandlerCollection.java:114)
	at org.mortbay.jetty.handler.HandlerWrapper.handle(HandlerWrapper.java:152)
	at org.mortbay.jetty.Server.handle(Server.java:324)
	at org.mortbay.jetty.HttpConnection.handleRequest(HttpConnection.java:535)
	at org.mortbay.jetty.HttpConnection$RequestHandler.content(HttpConnection.java:880)
	at org.mortbay.jetty.HttpParser.parseNext(HttpParser.java:747)
	at org.mortbay.jetty.HttpParser.parseAvailable(HttpParser.java:212)
	at org.mortbay.jetty.HttpConnection.handle(HttpConnection.java:404)
	at org.mortbay.io.nio.SelectChannelEndPoint.run(SelectChannelEndPoint.java:409)
	at org.mortbay.thread.QueuedThreadPool$PoolThread.run(QueuedThreadPool.java:520)

Can anyone help me?
Thank you, Francesco

The same problem happens also when, after adding a new row, I try to make whatever operation on other rows: if I try to delete a row, to insert another row, or also to setEditable(false)
I read on the forum about a bug in adding new rows fixed in 6.3.0 (
http://dev.vaadin.com/ticket/4299
). Is it possible this bug affects also my problem?
Thank you, Francesco

Replying to an old thread, so this might be obsolete…

The bug you mentioned is very unlikely to be related to your problem, it is more of a performance issue.

You do not mention what is the type of your bean, nor what container the table uses. Based on the stack trace, the container seems to be BeanItemContainer.

The first thing to check would be whether your bean correctly implement equals() and hashCode(), and that they are consistent with each other. As BeanItemContainer uses the bean both as the item id and the item contents, it needs proper implementations of these methods to enable e.g. lookups in Java collections. Also, are all the beans inserted to the collection of the same type? Is the BeanItemContainer correctly configured for that type?

If these do not help, more information would be useful.

Henri,
thank you for yor help. My problem is still here and I’m glad you are trying to help me. I post some code to give you some clue.
This is my bean, with equals and hashCode:

@Entity
public class TrattaTrasferta extends GenericModel implements Serializable {	
	private static final long serialVersionUID = 1L;
	
	@ManyToOne
	@JoinColumn(name="idTrasferta")	
	private Trasferta idTrasferta;
	
	@Column(nullable=false)
	private Integer numTratta;
	
	@Column(nullable=false)
	private Date tmsInizio;

	@Column(nullable=false)
	private Date tmsFine;
	
	@Column(nullable=false)
	private String desPartenza;

	@Column(nullable=false)
	private String desArrivo;

	@Column(nullable=false)
	private Long qtaDistanza;
	
	@ManyToOne
	@JoinColumn(name="idMezzoTrasporto",nullable=true)	
	private MezzoTrasporto idMezzoTrasporto;

	public Trasferta getIdTrasferta() {
		return idTrasferta;
	}

	public void setIdTrasferta(Trasferta idTrasferta) {
		this.idTrasferta = idTrasferta;
	}

	public Integer getNumTratta() {
		return numTratta;
	}

	public void setNumTratta(Integer numTratta) {
		this.numTratta = numTratta;
	}

	public Date getTmsInizio() {
		return tmsInizio;
	}

	public void setTmsInizio(Date tmsInizio) {
		this.tmsInizio = tmsInizio;
	}

	public Date getTmsFine() {
		return tmsFine;
	}

	public void setTmsFine(Date tmsFine) {
		this.tmsFine = tmsFine;
	}

	public String getDesPartenza() {
		return desPartenza;
	}

	public void setDesPartenza(String desPartenza) {
		this.desPartenza = desPartenza;
	}

	public String getDesArrivo() {
		return desArrivo;
	}

	public void setDesArrivo(String desArrivo) {
		this.desArrivo = desArrivo;
	}

	public Long getQtaDistanza() {
		return qtaDistanza;
	}

	public void setQtaDistanza(Long qtaDistanza) {
		this.qtaDistanza = qtaDistanza;
	}

	public MezzoTrasporto getIdMezzoTrasporto() {
		return idMezzoTrasporto;
	}

	public void setIdMezzoTrasporto(MezzoTrasporto idMezzoTrasporto) {
		this.idMezzoTrasporto = idMezzoTrasporto;
	}


	@Override
	public int hashCode() {
		final int prime = 31;
		int result = super.hashCode();
		result = prime * result
				+ ((desArrivo == null) ? 0 : desArrivo.hashCode());
		result = prime * result
				+ ((desPartenza == null) ? 0 : desPartenza.hashCode());
		result = prime * result
				+ ((numTratta == null) ? 0 : numTratta.hashCode());
		result = prime * result
				+ ((qtaDistanza == null) ? 0 : qtaDistanza.hashCode());
		result = prime * result + ((tmsFine == null) ? 0 : tmsFine.hashCode());
		result = prime * result
				+ ((tmsInizio == null) ? 0 : tmsInizio.hashCode());
		return result;
	}


	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (!super.equals(obj))
			return false;
		if (getClass() != obj.getClass())
			return false;
		TrattaTrasferta other = (TrattaTrasferta) obj;
		if (desArrivo == null) {
			if (other.desArrivo != null)
				return false;
		} else if (!desArrivo.equals(other.desArrivo))
			return false;
		if (desPartenza == null) {
			if (other.desPartenza != null)
				return false;
		} else if (!desPartenza.equals(other.desPartenza))
			return false;
		if (numTratta == null) {
			if (other.numTratta != null)
				return false;
		} else if (!numTratta.equals(other.numTratta))
			return false;
		if (qtaDistanza == null) {
			if (other.qtaDistanza != null)
				return false;
		} else if (!qtaDistanza.equals(other.qtaDistanza))
			return false;
		if (tmsFine == null) {
			if (other.tmsFine != null)
				return false;
		} else if (!tmsFine.equals(other.tmsFine))
			return false;
		if (tmsInizio == null) {
			if (other.tmsInizio != null)
				return false;
		} else if (!tmsInizio.equals(other.tmsInizio))
			return false;
		return true;
	}
	
}

This is the superclass:

@MappedSuperclass
public class GenericModel implements Serializable {
	private static final long serialVersionUID = 1L;
	
	@Id
	@GeneratedValue(strategy = javax.persistence.GenerationType.AUTO)
	@Column(name = "id",nullable=false)
	private Long id;
	
	@Column(nullable=false, length=50)
	private String userid;
	
	@Column(nullable=false)
	private Date changeDate;
	
	@Column(nullable=false)
	private Date initialDate = new Date();
	

	
	public Long getId() {
		return id;
	}
	public void setId(Long id) {
		this.id = id;
	}
	public String getUserid() {
		return userid;
	}
	public void setUserid(String userid) {
		this.userid = userid;
	}
	public Date getChangeDate() {
		return changeDate;
	}
	public void setChangeDate(Date changeDate) {
		this.changeDate = changeDate;
	}
	public Date getInitialDate() {
		return initialDate;
	}
	public void setInitialDate(Date initialDate) {
		this.initialDate = initialDate;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((id == null) ? 0 : id.hashCode());
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		GenericModel other = (GenericModel) obj;
		if (id == null) {
			if (other.id != null)
				return false;
		} else if (!id.equals(other.id))
			return false;
		return true;
	}

}

This is my Table. The Container is a BeanItemContainer, filled by a List read from db.

@Configurable(preConstruction = true)
public class TrattaTrasfertaTable extends Table{

	private static final long serialVersionUID = 1L;

	private Trasferta myTrasferta;

	@Autowired
	private transient TrattaTrasfertaService trattaTrasfertaService;

	@Autowired
	private transient VaadinApplicationObjectSupport app;


	public TrattaTrasfertaTable(Trasferta t) {
		super();
		myTrasferta=t;
		setSizeFull();

		List<TrattaTrasferta> trattaTrasfertas = trattaTrasfertaService.retrieve(" where f.idTrasferta=:trasferta order by f.numTratta","trasferta",myTrasferta);
		
		BeanItemContainer<TrattaTrasferta> bic = trattaTrasfertaService.list2Container(trattaTrasfertas);
		
		setContainerDataSource(bic);
		setVisibleColumns(new Object[] {"numTratta", "tmsInizio", "tmsFine", "desPartenza", "desArrivo","qtaDistanza", "idMezzoTrasporto" });

		setColumnHeader("numTratta", app.getMessage("tablestrutturale.numero"));
		setColumnHeader("tmsInizio", app.getMessage("tablestrutturale.datainizio"));
		setColumnHeader("tmsFine", app.getMessage("tablestrutturale.datafine"));
		setColumnHeader("desPartenza", app.getMessage("trattatrasferta.partenza"));
		setColumnHeader("desArrivo", app.getMessage("trattatrasferta.arrivo"));
		setColumnHeader("qtaDistanza", app.getMessage("trattatrasferta.distanza"));
		setColumnHeader("idMezzoTrasporto", app.getMessage("trattatrasferta.mezzotrasporto"));

		setColumnWidth("numTratta", 50);
		setColumnWidth("qtaDistanza", 50);

		setColumnCollapsingAllowed(false);
		setColumnReorderingAllowed(true);
			

		setPageLength(4);
		setSelectable(true);
		setImmediate(true);
		setNullSelectionAllowed(false);
		
	}

	public void setMyTrasferta(Trasferta myTrasferta) {
		this.myTrasferta = myTrasferta;
	}


	public Trasferta getMyTrasferta() {
		return myTrasferta;
	}

}

This is the FieldFactory:

@Configurable(preConstruction = true)
public class TrattaTrasfertaTableFieldFactory extends DefaultFieldFactory {
		/**
		 * 
		 */
		private static final long serialVersionUID = 1L;
		@Autowired
		private transient MezzoTrasportoService mezzoTrasportoService;
		
		
	    public TrattaTrasfertaTableFieldFactory() {
	    	super();
	    }
	    
		@Override
		public Field createField(Container container, Object itemId, Object propertyId, Component uiContext) {
	        if (propertyId.equals("idMezzoTrasporto")) {
	            return getMezzoTrasportoSelect(itemId);
	        }
	        final Field f = super.createField(container, itemId, propertyId, uiContext);
	        if (f != null) {
	            if (f instanceof TextField) {
	                TextField tf = (TextField) f;
	                tf.setWidth("100%");
	                tf.setNullRepresentation("");
	            }
	            
	            if (propertyId.equals("tmsInizio")) {
	                ((DateField) f).setResolution(DateField.RESOLUTION_MIN);
	                
	            }
	            if (propertyId.equals("tmsFine")) {
	                ((DateField) f).setResolution(DateField.RESOLUTION_MIN);
	            }
	        }
	        return f;
		}

		private Map<Object, Select> workoutIdToSelect = new HashMap<Object, Select>();
		
		private Field getMezzoTrasportoSelect(Object itemId) {
			Select cb = workoutIdToSelect.get(itemId);
	        if (cb == null) {
	            final Select cb2 = new Select();
	            
	            List<MezzoTrasporto> l = mezzoTrasportoService.retrieve("");
	                        
	            cb2.setContainerDataSource(mezzoTrasportoService.List2Container(l));
	            cb2.setItemCaptionPropertyId("desMezzoTrasporto");
	            cb2.setNewItemsAllowed(true);

	            workoutIdToSelect.put(itemId, cb2);
	            cb = cb2;
	        }
	        return cb;
	    }
}

and this is how table is created:

	public TrattaTrasfertaTable getTrattaTrasfertaTable() {
		if (trattaTrasfertaTable == null) {
			trattaTrasfertaTable = new TrattaTrasfertaTable(myTrasferta);
			trattaTrasfertaTable.setTableFieldFactory(new TrattaTrasfertaTableFieldFactory());
			
			trattaTrasfertaTable.setSizeFull();
		}		
		return trattaTrasfertaTable;
	}

New items in the table are added in this way:

	@Override
	public void nuovaTrattaClicked() {
		
		TrattaTrasferta tt = new TrattaTrasferta();
		tt.setIdTrasferta(myTrasferta);
		
        Object newItemId = trattaTrasfertaTable.addItem(tt);
        trattaTrasfertaTable.setValue(newItemId);
        
        trattaTrasfertaTable.setEditable(true);
        
	}

Table is in editable mode. Pressing save button, each row is persisted:

	@Override
	public void salvaTrasfertaClicked() {
			
		trattaTrasfertaTable.commit();
		
		for (Iterator i =trattaTrasfertaTable.getItemIds().iterator(); i.hasNext();) {
			TrattaTrasferta tt = (TrattaTrasferta) i.next();
			
			try {
				trattaTrasfertaService.save(tt);
			} catch (DatiObbligatoriException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}	
		}			
		getApplication().getMainWindow().showNotification(app.getMessage("formstrutturale.updated"));
		
	}

Thank you again, Francesco