1. #1
    Sencha User
    Join Date
    Nov 2008
    Location
    Vienna - Austria
    Posts
    867
    Answers
    9
    Vote Rating
    1
    micgala is on a distinguished road

      0  

    Default Unanswered: Is there something like a BaseModel?

    Unanswered: Is there something like a BaseModel?


    Hi.

    I liked very much the new way gxt is handling models, using PropertyAccess and so on.

    But I have troubles identifying how to handle generic models...

    For example, imagine I read my data from an xml, but I don't know how many properties will be there, and the names of those properties. So, I cannot create a bean to that, with getters and setters.

    Can someone please tell me how to handle this in gxt 3?
    In gxt 2, I was simply using the BaseModel... is there something similar for gxt 3?

    Thanks and regards,
    Michel.

  2. #2
    Ext GWT Premium Member dardison's Avatar
    Join Date
    Apr 2008
    Location
    Buenos Aires, Argentina
    Posts
    168
    Vote Rating
    1
    dardison is on a distinguished road

      0  

    Default


    The BaseModelData is still there in GXT 3.0 at:
    the legacy package com.sencha.gxt.legacy.client.data I think you can used it if you want.

    We have also a heavily use of BaseModelData in our GXT 2.x codebase but we decided to move that to Pojos because we think is the better way
    In case of the problem you mentioned you still can resolved with pojos I think.

    Regards.
    Daniel

  3. #3
    Sencha - GXT Dev Team
    Join Date
    Feb 2009
    Location
    Minnesota
    Posts
    2,634
    Answers
    107
    Vote Rating
    79
    Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice Colin Alworth is just really nice

      0  

    Default


    For example, imagine I read my data from an xml, but I don't know how many properties will be there, and the names of those properties. So, I cannot create a bean to that, with getters and setters.
    Remember that ValueProvider is just an interface, and can be implemented in any way you want, on any POJO you want. As Daniel mentioned, BaseModel is in the legacy jar, along with a ValueProvider implementation that can use it.

    If you can make any kind of a pojo with methods to get and set methods, and some way to translate your xml into data in the pojo, you can write a ValueProvider (and a ModelKeyProvider of course) that can generically access your data. Could look something like this:

    Code:
    interface XmlData {
      String getAttr(String key);
      void setAttr(String key, String value);
    }
    
    class XmlDataValueProvider implements ValueProvider<XmlData, String>{
      private String attr;
      public XmlDataValueProvider(String attrName) {
        this.attr = attrName;
      }
      public String getValue(XmlData data) {
        return data.getAttr(this.attr);
      }
      public void setValue(XmlData data, String value) {
        data.setAttr(this.attr, value);
      }
      public String getPath() {
        // this is only used to send keys to the server for sorting, etc, may not be required for you
        return attr;
      }
    }

  4. #4
    Sencha User
    Join Date
    Nov 2008
    Location
    Vienna - Austria
    Posts
    867
    Answers
    9
    Vote Rating
    1
    micgala is on a distinguished road

      0  

    Default


    Tks for the reply, guys!

Thread Participants: 2

film izle

hd film izle

film sitesi

takipci kazanma sitesi

takipci kazanma sitesi

güzel olan herşey

takipci alma sitesi

komik eğlenceli videolar