Announcement

Collapse
No announcement yet.
X
  • Filter
  • Time
Clear All
new posts

    GWT MVP Pattern with Nested Views

    I'm using SmartGWT 2.4 version on IE 7.

    If my application needs to use nested views :

    +----------------------------+
    | V1 |
    | +-------+ +-------+ |
    | | V2 | | V3 | |
    | | | |--------| |
    | | | | V4 | |
    | +-------+ +-------+ |
    | |
    | |
    +----------------------------+

    (1) is it recommended to have nested presenters as well (one presenter per view) ?


    (2) How do I handle events (in which presenter) across views? Example a Link in V2 that opens a tab in say V3?


    (3) How do I confine a refresh to just a particular subview V3 without refreshing the entire container through the AppController class ?

    Thanks,
    Uma







    Be sure your post includes:

    1. the SmartGWT or SmartClient version and browser version(s) involved;

    2. for a server-side problem, the complete logs generated during processing of the request;

    3. for a client-side problem, the contents of the Developer Console (see FAQ for usage);

    4. if there is a JavaScript error, the stack trace logged in the Developer Console (from Internet Explorer if possible); and

    5. sample code.

    Posts with incomplete information are much more likely to be ignored.

    #2
    MVP is a pattern for plain GWT, but is not recommended as a pattern for SmartGWT (which already includes a more sophisticated pattern). Our CTO Charles Kendrick explains in more detail here.

    Comment


      #3
      Hello,

      after looking at some MVP sample called Serendipity at
      http://uptick.com.au/content/serendipity-working-gwt-platform-and-smartgwt

      I agree, MVP seems to be way much over-engineered for my case, where the UI does not need to be swapable.

      @uiyer, the Serendipity is an excellent work and great learning,
      showing smartGWT in combination with MVP, gwtp, guice and gin.
      However look at it from a perspective how you would do it with 'plain' smartGWT and see how much code would be obsolete.
      Probably best is to check both ways and balance pros and cons to find your answer.

      @Isomorphic
      While I would not go for MVP, since I don't see a need for my project,
      I would still like to have UI components in a page more loosely coupled
      by some kind of event mechanism.
      Say a navigation item sends an event with some parameter, e.g. 'products', to tell, user has clicked on 'products' link.
      Other components can subscribe to this event and react,
      e.g. a ListGrid would register and show products upon this even has been received.
      Both components do not know about each other.

      I have seen discussions about an EventBus/MessageBus with public/subscribe in this forum.
      Would an EventBus be suitable in SmartGWT architecture from an isomorphic point of view, or would you suggest any other approach ?
      Or would you even say, loosely coupled components are also not needed ?

      Thank you,
      Daniel

      Comment


        #4
        Loose coupling can be overkill too, but it certainly applies to more use cases than a swappable UI layer.

        The problem with both is that a lot of developers "get religion", think of it as an inherently good thing to apply to any application, and write 10,000 line HelloWorld applications that do nothing but MVP and loose coupling :)

        A scenario where loose coupling is required: you're writing a portal and several different teams are writing widgets that appear in the portal. The widgets want to coordinate on state that's global to the portal (eg selected "Account" in CRM) but they aren't even compiled together, so they definitely can't reference each other directly. They should use a PubSub (publish/subscribe) mechanism to coordinate.

        A scenario where loose coupling is overkill: you're writing a custom component that is composed of other components that interact with each other. Just have your interior components hold references to each other and/or to the container component. You are already behind an encapsulation boundary and do not need to loosely couple your interior components.

        That all said - if you're in a scenario where you have an actual need for loose coupling, we currently recommend either using the GWT wrapper for TIBCO pagebus or rolling your own (it's pretty simple).

        Finally, one thing to make clear about swappable UIs and MVP: a real scenario for a "swappable UI" is needing to make the same data services available to different kinds of clients, for example, a web browser, a Java Swing application, and an automated process.

        SmartGWT Pro+ automatically handles this scenario because there is an included RestHandler servlet that provides Rest-based access to the same data services your SmartGWT UI components use, with the same security rules, business logic and so forth, with no additional effort.

        The "swappable UI" capability that MVP would enable is two different GWT-based UIs using the same GWT-based data services. This is an extremely rare requirement (we've honestly not seen it), much rarer than needing REST-based access for other UI technologies, and SmartGWT handles this use case neatly without the use of MVP anyway (two UIs can simply use the same DataSources in SmartGWT).

        Comment


          #5
          What about offering undo-redo support in your web application? Is this something that SmartGwt will ever support as part of the library?

          This is one the reasons I'd like to implement my components using some kind action/event bus architecture. The other reason not mentioned above, is the ability to track and analyze the user experience (flow of actions, which buttons are being used in which order, etc).

          Comment


            #6
            Undo/Redo is usually based on the Command Pattern. What you need in order to get this pattern right is to execute specific user actions via a Command pattern instead of just directly affecting some target component.

            Neither MVP nor an Event Bus particularly help with this. You want to capture very high level user actions for undo/redo and MVP is at the wrong layer (plumbing individual bits of data to components) and a general-purpose Event Bus likewise has lots of chatter on it, most of which should not be encapsulated as a Command.

            But, yes, Undo/Redo support is planned as a feature (no specific target yet).

            As far as analytics / tracking - a lot depends on granularity. If you just want to track things that warrant Undo/Redo support, just tack analytics onto your Command pattern. For lower-level tracking, there's what Selenium does.

            Comment

            Working...
            X