melistik / vaadin-grid-util

simplify the use of vaadin's grid and add features
https://vaadin.com/directory/component/gridutil
MIT License
32 stars 21 forks source link

NoSuchElementException #49

Closed allenvpn312 closed 6 years ago

allenvpn312 commented 6 years ago

Hi, I have been using GridUtil since Vaadin 7, great work! I am currently porting my app from Vaadin 7 to 8 and having an issue with the GridCellFilter. I am using Grid-Util 2.1.0.

My dataprovider is a ListDataProvider so no problem here.

private ListDataProvider<ImportFilingRecord> dataProvider = null; records = importFiling.getImportFilingRecords(); dataProvider = DataProvider.ofCollection(records); grid.setDataProvider(dataProvider);

The grid column is defined as so:

grid.addColumn(ImportFilingRecord::getShippingDocumentNo).setId("shippingDocument").setCaption("DOCUMENT").setWidth(200);

My filter is defined as so:

final GridCellFilter<ImportFilingRecord> filter = new GridCellFilter<ImportFilingRecord>(grid, ImportFilingRecord.class); filter.setTextFilter(grid.getColumn("shippingDocument").getId(), true, true);

The filter textfield shows up fine but when I enter a value to filter, I get the following exception:

java.util.NoSuchElementException: No value present

Please advise as to what is causing the issue.

Thank you.

arminvukovic commented 6 years ago

Hi @allenvpn312 ,

the java.util.NoSuchElementException is most likely thrown because your bean ImportFilingRecord doesn't have a property with the name shippingDocument...

GridCellFilter will try to get a getter for the values of the collumn to be filtered over the specified collumnId via following call:

((PropertyDefinition)this.propertySet.getProperty(columnId).get()).getGetter()

This call will fail if your collumnId doesn't match a property of your bean because the propertySet is created with the following call:

this.propertySet = BeanPropertySet.get(beanType);

The same issue when using persistence and having bi-directional associations via foreign keys... It would be great if we had a way to pass the ValueProvider into the filter or even if the filter would consider the propertySet of the nested beans too.

I hope it helps... Regards!

allenvpn312 commented 6 years ago

Thanks for the quick comment. I went through the code and fixed it accordingly. I do agree it would be great to pass the ValueProvider into the filter in order to read nested beans. Keep up the great work!!!

arminvukovic commented 6 years ago

Well, this is not my work I am too just an amazed user :)

Anyway, I'am glad I could help. Chears!