1. #1
    Ext User
    Join Date
    Apr 2008
    Posts
    376
    Vote Rating
    0
    zaccret is on a distinguished road

      0  

    Lightbulb ModelData and displayProperty

    ModelData and displayProperty


    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
    Code:
    public String getDisplayText();
    in a Model interface, a
    Code:
    public Object getSortValue();
    in a SortableModel sub-interface, etc...
    Other possibility would be that model-based components rely on a ModelDisplayProvider class with a
    Code:
    public String getDisplayText(M model);
    Would it be possible to slightly reconsider/enhance the Model API ? Thoughts ?

  2. #2
    Ext GWT Premium Member gslender's Avatar
    Join Date
    Mar 2008
    Location
    Brisbane, Australia
    Posts
    1,572
    Vote Rating
    2
    gslender is on a distinguished road

      0  

    Default


    +1

  3. #3
    Ext User
    Join Date
    Jun 2008
    Posts
    365
    Vote Rating
    0
    sdc is on a distinguished road

      0  

    Default


    About the displayProperty, other idea here : http://extjs.com/forum/showthread.ph...202#post184202

  4. #4
    Ext User
    Join Date
    Jun 2008
    Posts
    365
    Vote Rating
    0
    sdc is on a distinguished road

      0  

    Talking


    Actually, it is the same idea (ModelDisplayProvider)

  5. #5
    Ext User
    Join Date
    Apr 2008
    Location
    Munich, Germany
    Posts
    43
    Vote Rating
    0
    flow is on a distinguished road

      0  

    Default


    +1

  6. #6
    Ext User
    Join Date
    Jun 2008
    Location
    Utrecht, Netherlands
    Posts
    24
    Vote Rating
    0
    assassin is on a distinguished road

      0  

    Default


    +1

  7. #7
    Ext User
    Join Date
    Apr 2008
    Posts
    376
    Vote Rating
    0
    zaccret is on a distinguished road

      0  

    Default


    Darell, what is your opinion on that point ?

  8. #8
    Ext User
    Join Date
    Jun 2008
    Posts
    365
    Vote Rating
    0
    sdc is on a distinguished road

      0  

    Question


    Darell, JavaBean support is really really really nice !! But we still have to manage string properties (displayProperty for ComboBox, column ids for tables) to tell the widget how to display the text.

    I think it would be a nice enhancement on the API to have objects (ModelDisplayProvider for ComboBox and for TableColumns ?) telling how to display text instead of setting the name of a property (not type-safe).

  9. #9
    Ext User
    Join Date
    Apr 2008
    Posts
    376
    Vote Rating
    0
    zaccret is on a distinguished road

      0  

    Default


    By the way, it was possible with the old Viewer API at least for trees. There was a LabelProvider class, which was equivalent to the ModelDisplayProvider we are talking about.

  10. #10
    Ext User
    Join Date
    Apr 2008
    Posts
    30
    Vote Rating
    0
    abickford is on a distinguished road

      0  

    Default


    If i remember correctly that's how the API used to look. It was based off the JFace API from SWT. Now it's based of the store/binder/loader/proxy/model API of EXT. I believe it was a licensing issue involving the EPL.

    I prefer the JFace API, the EXT one takes far too much work for even the simplest cases. It's also a little too 'clever' for me.