SQLContainer-backed table - one row at the time edit issue

Hello!

I’m having hard time figuring out what’s wrong and how to make it right. Ok, so here is what I have.

I’m trying to make single row in SQLContainer backed table editable. For that, I have added generated column with an ‘Edit’ button. Basically here is how it goes:



@Override
public Object generateCell( final Table source, final Object itemId, final Object columnId ) {
	HorizontalLayout layout = new HorizontalLayout();
	layout.addComponent( new Button( AppBundle.getMsg( "gui.actions.editName" ), new Button.ClickListener() {

	/**
	 * 
	 */
	private static final long	serialVersionUID	= 1L;

	@Override
       	public void buttonClick( final ClickEvent event ) {
					
	SQLContainer container = (SQLContainer) source.getContainerDataSource();

	Collection<?> pids = container.getContainerPropertyIds();

	for ( int i = 0; i < container.size(); i++ ) {
		Object iid = container.getIdByIndex( i );
		for ( Object pid : pids ) {
			container.getContainerProperty( iid, pid ).setReadOnly( true ); // <--- (1)
		}
	}
			
	container.getItem( itemId ).getItemProperty( "nazwa" ).setReadOnly( false );
	source.setEditable( true );
	source.refreshRowCache(); // <--- (2)
	}
        } ) );
	return layout;
}

It works as I expect it to work for very small sets of data. However I get unexpected behavior when it comes to sets containing ~250 items. It seems like line marked with (1) had no significance at all. It gets executed, and it actually updates the readOnly state. It must be overwritten somwhere later in the framework I have no idea where. Thing is, I am using Vaadin for like a week so I am kind of newbie here.

What I am asking about is how should I do this to work like I want it to.

Also there is line marked (2) issue. I would like to ask You if there is maybe some more lightweight way to do this?

Oh and one more thing. I am using FreeformQuery with FreeformStatementDelegate attached.

Regards,
RG.