setSelectionMode vs setSelectionModel

This is one of the things I hate about Vaadin, so be prepared for a lot of angry ranting :stuck_out_tongue:

Couldn’t these names had ever been chosen a bit more confusing? Everytime I want to check or set the selection mode I have to check the docs because I don’t remember which method to use. And even after doing so, I need to do a couple tests to get my code wowrking because it’s not clear enough.

Maybe it’s my fault and I haven’t got it in the proper sense. Why those names are so similar? Is it done on purpose? Is there any mnemotechnic rule to remember it the next time? In case there isn’t a reason for this name convention, could you create an alias or so for one of the names and include it in the next release, so I can stop using one of them and completely forget having to do this distinction which such a little difference as a single letter?

Thanks a lot…

Hey Pere,

I’m pretty sure with Vaadin 8.0.0+ there is no more setSelectionModel() .

Greetings,
Michael

You are totally right, Michael.

I checked
https://vaadin.com/docs/v8/framework/datamodel/datamodel-selection.html
in order to better document my rants, but it seems I looked at it too fast at the 1st sight.

Then, appart from my absurd comment, this is good news. And another incentive to definitely migrate to v8, too :wink:

It goes like this

Grid grid = new Grid(myContainer);

// uses the bundled SingleSelectionModel class
grid.setSelectionMode(SelectionMode.SINGLE);

// changes the behavior to a custom selection model
grid.setSelectionModel(new MyTwoSelectionModel());

So mnemotechnic rule is that Model is the class to be used, and Mode is the enum.

Why there is two methods, it is due legacy reasons. In older versions of framework there was no support for custom selection models, it was added later. I.e. the grid.setSelectionMode already was there, but could not be used for new feature, hence grid.setSelectionModel needed to be added. This to prevent breaking backwards compatibility.