Dialog with Grid unable to bind nested entity

Hi All,
I’m following a sample from [start flow]
(https://github.com/vaadin/beverage-starter-flow).

My entities are shown below, I tested my Repositories and entities with a Rest Controller and I can successfully do CURD operations.
Now I’m trying to tie my Document Entity to a Dialog object (just like the one used in the start flow project), and I would like to display my Document.links as a grid.
Problem is I don’t know how to attach the Grid’s dataProvider to the Documents.links variable

public class Document extends AbstractEntity {
	private String description;
	private Set<Links> links;
	... get/set
}	
public class Links extends AbstractEntity {	
	private String description;	
	... get/set
}	

Then I extended the AbstractDialog like so:

public class DocumentEditorDialog extends AbstractEditorDialog<Document> {
    public DocumentEditorDialog(BiConsumer<Document, Operation> saveHandler,
            Consumer<Document> deleteHandler) {
    	super("document", saveHandler, deleteHandler);
        setUpForm();
    }
    private void setUpForm() {
		
    	description.setPlaceholder("Description");
		description.setLabel("Description");		
		getBinder().forField(description)
			.bind(Document::getDescription,Document::setDescription);
		
		//How to bind the Grid's data provider to this Dialog's Document entity?
		linkGrid.setDataProvider(linkDataProvider);
		
		Grid.Column<Links> descriptionColumn = linkGrid.addColumn(Links::getDescription)
				.setHeader(new Label("Description"));
				
		Grid.Column<Links> editColumn = linkGrid.addColumn(new ComponentRenderer<>(this::createLinksEditButton))
					.setFlexGrow(0);			
		
		topRow = linkGrid.prependHeaderRow();
		buttonsCell = topRow.join(descriptionColumn,urlColumn,editColumn);
					
		getFormLayout().add(linkGrid);
		
	}
	...
}

My UI looks something like this:
[image]
(https://drive.google.com/open?id=1PNIeYq_W7q2Rl2W_GsMB_l4AFJ_ZyMar)

Hi Cesar

You need the Document instance in order to get its links. I see that you are using a binder - If you used binder.setBean(document) you can get the document instance via binder().getBean(), and if you used binder.readBean(document) you need to pass the document somehow into the DocumentEditorDialog, I would pass it into the constructor.

Now that you have the document instance, you can get its links through document.getLinks(), to create the grids dataProvider with them:

// setItems() shortcut will create a data provider using the given set document.getLinks()
linkGrid.setItems(document.getLinks());

// if you need access to the data provider for further configuration (for example sorting), you can use this
ListDataProvider<Links> dataProvider = DataProvider.ofCollection(document.getLinks());
dataProvider.setSortOrder(Links::getDescription, SortDirection.ASCENDING); // example sorting configuration
linkGrid.setDataProvider(dataProvider);