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

java.util.NoSuchElementException: No value present on GridCellFilter.setDateFilter #55

Open mattgolem opened 5 years ago

mattgolem commented 5 years ago

I create a grid with initial no data and I get error on GridCellFilter.setDateFilter(dateColumn).

stack trace is:

java.util.NoSuchElementException: No value present
    at java.util.Optional.get(Optional.java:135) ~[na:1.8.0_151]
    at org.vaadin.gridutil.cell.GridCellFilter.setDateFilter(GridCellFilter.java:511) ~[vaadin-grid-util-2.1.1.jar:2.1.1]
    at org.vaadin.gridutil.cell.GridCellFilter.setDateFilter(GridCellFilter.java:498) ~[vaadin-grid-util-2.1.1.jar:2.1.1]

the bug code is:

public RangeCellFilterComponent<DateField, HorizontalLayout> setDateFilter(String columnId, java.text.SimpleDateFormat dateFormat, boolean excludeEndOfDay) {
        Class<?> propertyType = propertySet.getProperty(columnId)
                .get()
                .getType();
        if (!Date.class.equals(propertyType)) {
            throw new IllegalArgumentException("columnId " + columnId + " is not of type Date");
        }
...
mattgolem commented 5 years ago

In my case columnId and propertyName are different

admlke commented 5 years ago

This is the case, it must be the same