Can't set initial value of ComboBox using DefaultFieldFactory

Hello there. I’m new on Vaadin and need some help. I’ve got a database that consists of two tables:
projectsTable
, that contains the information of different Projects including the id of the person in charge (
idUser
), which is the primary key of the second table named
usersTable
. The SQLContainers
containerProjects
and
containerUsers
contains the information of each Table respectively.

I want to show some relevant information of the
projectsTable
through a Form (
formProjects
), and allow the client to edit the fields of the Form when selects a row of the Table
projectsTable
. I’m using a comboBox to display the names of the different possible users that can be set to the selected project. The problem is that when I select one project of
projectsTable
, the person in charge of the project is not displayed in the comboBox as initial value. I tried to set the initial value of ComboBox inside the class UserFieldFactory and I also tried to set it after the call of setFormFieldFactory(), but it doesn’t work.

Here I attach the code of the valueChangeEvent handler:

public void valueChange(ValueChangeEvent event) {
		// TODO Auto-generated method stub
		
		if(event.getProperty() == projectsTable){		
			
			buttonsLayout.addComponent(edit);
			
			formProjects.setReadOnly(false);
			formProjects.setFormFieldFactory(new UserFieldFactory(containerProjects.getItem(projectsTable.getValue())));
			formProjects.setItemDataSource(containerProjects.getItem(projectsTable.getValue()));
			
			//Tried to set the value here
//			try{
//				users.setValue(users.getItemIds().toArray()[Integer.parseInt(containerProjects.getItem(projectsTable.getValue()).getItemProperty("idUser").toString()) - 1]
);
//			}
//			catch(Exception e){
//				
//			}
			
			formProjects.setVisibleItemProperties(PROJECT_FORM);
			formProjects.setReadOnly(true);
			
		}
		
				
	}

The code of the class UserFieldFactory:

private class UserFieldFactory extends DefaultFieldFactory {
		

		private static final String COMMON_FIELD_WIDTH = "12em";
	
		ComboBox users = new ComboBox("User name");
		
		 public UserFieldFactory(Item item) {
			 

			 users.setContainerDataSource(containerUsers);
			 users.setItemCaptionPropertyId("name");
			 users.setNullSelectionAllowed(false);
			 
			 
		 }
		 	
		 public Field createField(Item item, Object propertyId,
		            Component uiContext) {
		        Field f;
		        
		        if ("idUser".equals(propertyId)) {

		        	users.setWidth(COMMON_FIELD_WIDTH);
		        	users.setRequired(true);
		        	users.setImmediate(true);
		        	users.setRequiredError("This field must be completed");
		            return users;

		        } else {               
		        	f = super.createField(item, propertyId, uiContext);	
		        } 
		        
		        return f;
			}
	}
}

Any ideas of what could be the problem or what is missing?
Thanks in advance guys!

any idea ???