Loading...
Important Notice - Forums is archived

To simplify things and help our users to be more productive, we have archived the current forum and focus our efforts on helping developers on Stack Overflow. You can post new questions on Stack Overflow or join our Discord channel.

Product icon
TUTORIAL

Vaadin lets you build secure, UX-first PWAs entirely in Java.
Free ebook & tutorial.

Vaadin 8 and private BeanContainer

Fabio Ebner
5 years ago Mar 03, 2017 2:28pm
Alejandro Duarte
5 years ago Mar 06, 2017 3:29pm
Fabio Ebner
5 years ago Mar 07, 2017 3:52pm
Pekka Hyvönen
5 years ago Mar 07, 2017 4:25pm
Puja Kuamri
4 years ago Mar 29, 2018 9:54am
Alejandro Duarte
4 years ago Mar 29, 2018 11:25am
Yong Liu
4 years ago Mar 31, 2018 12:18am
Vilius Kukanauskas
4 years ago Apr 01, 2018 12:49pm
Tatu Lund
4 years ago Apr 01, 2018 4:45pm
Yong Liu
4 years ago Apr 04, 2018 10:51pm
Yong Liu
4 years ago Apr 04, 2018 10:54pm
Olli Tietäväinen
4 years ago Apr 05, 2018 5:34am
Yong Liu
4 years ago Apr 05, 2018 3:29pm
Vilius Kukanauskas
4 years ago Apr 05, 2018 6:38pm

@Yong Liu about Supplier.

As i understood, you wanted to add some Columns, which represent something, that is not in the bean. (maybe i also totaly misunderstood you, sorry if this is the case, it is late :)

As the Supplier gives you a at that moment when you are "asking" him to, withou you giving anything as request, i was thinking of it as possible Solution.

Example for Grid.

simple bean class

public class Pojo {

    private Long id;
    private String name;

    public Pojo(final Long id, final String name) {
        this.id = id;
        this.name = name;
    }
	//getter setter
}

a minimalistic grid that shell show the name of pojo, and also completely undependent column, something completely random :)

		Random rn = new Random();
        Supplier<Integer> supplier = () -> rn.nextInt(1000);
 
		Grid<Pojo> grid = new Grid<>();

        grid.addColumn(Pojo::getName)
                .setCaption("Name");
				
		 grid.addColumn(p -> supplier.get())
                .setCaption("TimeStamp");
		
		Collection<Pojo> pojos = new ArrayList<>();
        LongStream.range(0, 100)
                .forEach(i -> pojos.add(new Pojo(i, "Pojo Nr.:" + String.valueOf(i))));

        grid.setItems(pojos);
	as a result, i got this grid

I dont know if it is fitting for you, just wanted to show a way of adding columns, that have nothing to do with the actual bean. If you want something like this but to give Bean as a Parameter, try "Function<T, R>"

Represents a function that accepts one argument and produces a result.

Vilius Kukanauskas
4 years ago Apr 05, 2018 7:23pm
Yong Liu
4 years ago Apr 06, 2018 3:42am
Vilius Kukanauskas
4 years ago Apr 06, 2018 6:00am
Yong Liu
4 years ago Apr 06, 2018 2:13pm
Vilius Kukanauskas
4 years ago Apr 06, 2018 10:28pm
Yong Liu
4 years ago Apr 09, 2018 2:01pm
Vilius Kukanauskas
4 years ago Apr 09, 2018 4:15pm
Yong Liu
4 years ago Apr 10, 2018 7:39pm
Vilius Kukanauskas
4 years ago Apr 11, 2018 10:57am
Yong Liu
4 years ago Apr 11, 2018 4:04pm
Vilius Kukanauskas
4 years ago Apr 11, 2018 6:21pm
Yong Liu
4 years ago Apr 11, 2018 7:04pm
Vilius Kukanauskas
4 years ago Apr 11, 2018 9:11pm
Yong Liu
4 years ago Apr 12, 2018 2:28am
Vilius Kukanauskas
4 years ago Apr 12, 2018 6:07am