Originally posted by Jasiek Motyka:
Should I then seperate view specific state ("selected", position) from model and move it directly to the view? I understand not every view would have the same state.
That's what I tend to do. YMMV, of course.
The other doubt I have is, whether "selected" is in fact view specific. To be in a selected state means to behave sort of differently, so it is not only a matter of appearance. This is at least my point of view
The usual way I approach this is to make my models as stateless as I can manage. Although the
user may see things as a "select item", "operate on selected item", "select other item" style of workflow, this is not reflected in the model. The model provides stateless, atomic, operations like "operate on item xx". One job of the view is to manage the idea of selection (if it matters, not all views will have this notion). Selecting one or more items is entirely a view operation. The model is ony affected if/when the user requests an operation, at which point the view requests the operation on the selected item(s).
If you have several views with similar selection semantics, it might be sensible to abstract the selection behaviour into some shared component, but that is still external to the model.
Does that make sense?