zaccret
12 Jun 2008, 6:02 AM
Models (ModelData <- Model <- etc...) support a form of "instrospection" as property names (String) and values can be retrieved at runtime. I guess this is great at least for internal use.
But when it comes to write some models for ComboBox, Tree, etc, I don't see how it is useful.
I mean : to tell the component which text it must displays, the model must set a property (name/value) and the model user must tell the component what is the name of the property (by default it is "text" for ComboBox, for example). IMHO it is not a good constraint because :
- it is not type-safe
- it can easily cause typo errors
- it introduces coupling (the model user must know the internal behaviour of the model : what is the name of the display property)
I think it would be nice to have something like
public String getDisplayText();
in a Model interface, a
public Object getSortValue(); in a SortableModel sub-interface, etc...
Other possibility would be that model-based components rely on a ModelDisplayProvider class with a
public String getDisplayText(M model); Would it be possible to slightly reconsider/enhance the Model API ? Thoughts ?
But when it comes to write some models for ComboBox, Tree, etc, I don't see how it is useful.
I mean : to tell the component which text it must displays, the model must set a property (name/value) and the model user must tell the component what is the name of the property (by default it is "text" for ComboBox, for example). IMHO it is not a good constraint because :
- it is not type-safe
- it can easily cause typo errors
- it introduces coupling (the model user must know the internal behaviour of the model : what is the name of the display property)
I think it would be nice to have something like
public String getDisplayText();
in a Model interface, a
public Object getSortValue(); in a SortableModel sub-interface, etc...
Other possibility would be that model-based components rely on a ModelDisplayProvider class with a
public String getDisplayText(M model); Would it be possible to slightly reconsider/enhance the Model API ? Thoughts ?