The "controller" in GWT should for most cases use the observer pattern, your model should support property change events and registering listeners. This gets around the action way of implementing a controller and is quite a bit more flexible since you could have multiple listeners for a single event. If your not already familiar with listeners you may want to look at some Swing applications since GWT and Swing both use the same Property Change Support mechanisms. Also "GWT In Practice" has some pretty good examples of how GWT is intended to be used in terms of an MVC approach if your interested in a book on the subject.
On Wed, Jan 28, 2009 at 1:17 PM, gregor <[email protected]>wrote: > > I would not get too hung up on the "Controller" part of MVC. I don't > know php, but it sounds the same as struts: cycles of pages (views) > rendered to client driven by action classes (controllers) that both > use a model (beans in Java speak). These action classes that drive > generation of the next view fit beautifully into MVC pattern as > controllers, but in a GWT application there is no need of them because > this work can be done on either the client or the server as > appropriate for the use case, and in general the more on the client > the better (keep as much state as possible on client). Therefore > exactly what a "controller" is in a GWT application is IMO a slippery > concept. > > I would recommend two things: > > 1) If you are starting a new project download 1.6 from trunk to take > advantage of the new Event model. It is much more powerful than the > existing <=1.5 event system. Unfortunately there is is little > documentation for it yet (even the javadoc is sparse) but I'm sure > questions about it would be answered here PDQ. Experimenting with this > will help you determine how you might best design your client GUI, > i.e. how your main components might best communicate between > themselves and when necessary with the server. > > 2) In an ideal (MVC) world what Ian calls "smarts" should live in > domain model classes, and these should flow freely across networks. As > Ian points out this is sometimes possible and sometimes (perhaps most > often) it isn't because we are dealing with a given technology stack > that we can't alter in the short term. I don't think there is any one > satisfactory answer to this question - every application has it's own > use cases that will rub up against technology stack limitations in > different ways. My point is that thinking about this (i.e. how to > implement a domain model in a real world stack) is much more important > than worrying about what a "controller" is. > > regards > gregor > > On Jan 28, 4:35 pm, Jason Essington <[email protected]> wrote: > > MVC is a good design pattern to use with GWT. > > If you are new to GWT, get Ryan Dewsbury's book "Google Web Toolkit > > Applications" it does a very good job of outlining exactly what is > > model, view and controller in each example project. > > > > -jason > > > > On Jan 28, 2009, at 9:10 AM, asdf_asdf wrote: > > > > > > > > > His, > > > > > I am new to GWT and evaluate it currently. Just happily went through > > > the official tutorial and full of questions taunting my mind. > > > Just a quick background (should my question seem a bit messy): I am > > > coming from php field and have in past have been using a mvc framework > > > (CodeIgniter) where links/forms on a single webpage are mapped to > > > methods of a controller responsible for calling buisiness logic and > > > putting together view components. So... > > > > > * Is MVC the recommended design pattern to develop GWT applications? I > > > see then the class implementing EntryPoint interface as being a > > > "controller", but what would be a view in that case? I am struggling > > > to understand the relationship between html-page and the controller > > > that gets called: does each controller get called by the html-page > > > that loads the appropriate javascript file and how could a controller > > > have methods mapped to specific a user actions. For instance, after a > > > specific link is clicked a new widget is shown (in the tutorial this > > > is achieved through listeners, but can there be a url to method > > > mapping as well)? > > > > > * In respect to tutorial, what does the attribute path="/stockPrices" > > > in <servlet> xml tag mean and the identical annotation > > > @RemoteServiceRelativePath("stockPrices") in service interface? I > > > assume that the server-side method gets called when under that url, > > > but how is the client aware of the mapping? > > > > > * So far I have only seen tutorials on implementing relatively easy > > > projects. Does anyone know if there a more powerful sample application > > > with open source available: something where there is a need for more > > > than one html-page and controller exist? > > > > > Many thanks, > > > Denis > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---
