Results 1 to 2 of 2

Thread: How to expose GXT Grid to GWT MVP Activity

  1. #1
    Sencha User
    Join Date
    Mar 2013

    Default How to expose GXT Grid to GWT MVP Activity

    Hi, Is there any best approache and/or interface that can be used to expose the GXT Grid to Activity from a View in GWT MVP without leaking the UI code in Activity. For example, I would expose Button/TextBox to Activity as like below from View:

    public interface UsersView extends isWidget {
        HasClickHandler getButton();
        HasText getUserText();
    I am trying to mean the similar thing - ?

  2. #2
    Sencha User
    Join Date
    Feb 2009


    Clearly you will need at least one more method there, as a Grid is not just a way of drawing text. One option would be to expose the ListStore in one of those methods so that the Presenter could replace the items or could wire the store into a loader. Another option would be for the presenter to *give* the view a ListStore, already loaded (or will be loaded from a loader as above).

    Interfaces are *not* required for this idea to work - they are necessary in some cases where multiple implementations could be used (i.e. HasText could talk about a TextBox or a Label), but all that is essential is a way to abstract out the behaviors. In this case, the ListStore actually holds the data, it is up to the view to decide how it draws that data - does it attach to a ListView? To a Grid? What columns does it want in that Grid?

    We don't tend to use HasClickHandlers because it isn't abstract enough - it doesn't talk about users focusing a button with the tab key, then activating it with the spacebar, and it doesn't address touch at all. Instead, we use HasSelectHandlers for the same idea, but grouping all logical "User wants to activate this button" behaviors. You'll still probably want something like that in order to save any changes the user made, or reload data, etc.

    One more point - the ListStore doesnt have to be the point of abstraction here. It could be a loader of some kind - if the view might want to have a PagingToolbar, it will need access to the Loader to bring in more items, so the View might entirely own the ListStore, and just ask the presenter for a loader, properly wired up as the Presenter wants.

    The purpose of MVP isn't to be a cookie cutter "This is how you write all code" - instead, it is a way of thinking about code to isolate concerns, make it easy to extend and modify code, and abstract out details so that the view or the presenter can be replaced as needs change (adding unit tests, adding a mobile implementation, etc).

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts