4

I am now migrating an applicaition from GXT 2 to GXT 3.

One of the major differences between the two is that GXT 3.x allows POJOs to be used in widgets, whereas GXT 2.x widgets require objects which implement ModelData.

The problem is that I cannot simply throw all the ModelData objects away and use POJOs, because ModelData objects contain a lot of additional properties, which are only relevant to the GUI.
So, these properties cannot be placed to the POJOs(real app model).

Most likely, I will end up building my own ModelData interface and a set of objects to use in widgets. Which looks a bit ugly and non-GXT3 styled.

Are there any any other approaches used to solve such a problem? Or maybe someone already faced it? Any advise is highly appreciated.

Andrew
  • 2,663
  • 6
  • 28
  • 50
  • Have you read `http://www.sencha.com/learn/sencha-gxt-2x-to-300-migration-guide/`? There's a section on `ModelData`. – Chris Phillipson Apr 04 '13 at 23:03
  • Yes, I did. That section says that I should use LabelProvider and KeyProvider to access properties in my beans. But I also used to access some GUI specific properties in filters, for example. So, using LabelProvider in such places does not seem to be a good idea. – Andrew Apr 05 '13 at 07:14
  • 1
    Perhaps a simple converter (adapter) approach? On my project we often perform client side mapping. A drag, but sometimes it's better than the alternative, a major refactoring. – Chris Phillipson Apr 06 '13 at 16:19

2 Answers2

0

Similar to Chris Phillipson's suggestion, you could subclass your POJOs with a client-side variant that adds the additional fields e.g. you have a class called MyPojo:

class MyPojo {
    private String name;
    private String address;
    ...
}

On the client you have subclass:

class MyClientPojo extends MyPojo {
     private String additionalInfo;
     ...
}
geofffro
  • 11
  • 2
0

My suggestion would be to create a YourModelData class of your own that wraps the YourModel class and adds the additional properties you might need for displaying (I would advise against subclassing for that purpose, since the ModelData is no YourModel, it only has one). There's nothing keeping you from using ModelData, but you no longer have to.

koljaTM
  • 10,064
  • 2
  • 40
  • 42