Thanks a lot, Gregor, for such full answer, and thanks for link About Controller, i meant that i want to separate business of creating item in group widget and removing from it from widget itself - it is only visual representation of list of groups. It only know that he can hold group, provide interface to manage it, but what exactly happen with group - it doesn't matter for widget.
" What works simplest usually works best." - gold phrase . Thanks Now, i provide two methods for some business action with group - first one notifies client app that widget created some group, calling controller method with newly created group as parameter - and second simple method to add new group to widget. So Controller implementor decides what to do with that "request for group creation" On 2 дек, 20:45, gregor <[EMAIL PROTECTED]> wrote: > Hi Rexalo, > > My 2c. What you seem to asking is if there is a standard "right" way > to do Model-View-Controller with GWT and/or what is the "best" way to, > as you put, "separate this transport/business layer fromwidget.". IMO > the answer is that there isn't a standard one, rather several options > or approaches. But I would search the group for "MVC" to get a flavour > of how many different opinions there are about this. Check this > discussion, for example, which is top of the list: > > http://groups.google.com/group/Google-Web-Toolkit/browse_thread/threa... > > IMO the difficulty is that both "Controller" and "Model" are slippery > concepts in an AJAX web application, whereas "View" is a straight > forward concept - it's awidgetof some kind. Some reasons are: > > 1) The real "Controller" in an AJAX application is the browser - > anything involving a change to the DOM ultimately runs through its > event queue (and it also handles request dispatches and fields the > responses as well), therefore it is natural forWidget(i.e. view) > classes to interact with the browser event queue directly, and this is > what GWT does. Because GWT widgets catch, process and sink events > routinely anyway it is difficult (but not impossible) to separate them > from a separate "Controller" in a clean or meaningful way. > > 2) What might we mean when we refer to a "Model" maintained client- > side in a GWT application? Is it the "real" domain model for the > application, some sub-set of it, or maybe a snapshot of some some sub- > set of it? If you think about it, the "real" domain model resides on > the server and ultimately whatever sub-set of this is transported to > the GWT client must at some point be reconciled with the "real" server > model (i.e. the one actually persisted to backing store) always > bearing in mind that another client might have changed the "real" > model independently in the meantime. > > Both these issues can introduce significant complexity. This is not to > say that there are not sometimes good reasons to introduce > "Controllers" and "Models" client side. An example might be a chat > application that uses blocking requests (i.e. comet style) to pick up > new messages. But it does imply that doing so introduces layers of > complexity to a GWT application that may be unnecessary. > > For these reasons I don't think it is automatically the case that "i > want to separate this transport/business layer fromwidget" is a > necessarily a good design/engineering decision in a GWT app. What > works simplest usually works best. However, sometimes it is and there > are several approaches to doing it - it depends on what you are > actually trying to achieve, not on a matter of (MVC) principle. > > regards > gregor > > On Dec 2, 1:01 pm, raxelo <[EMAIL PROTECTED]> wrote: > > > > > Hi, Gregor! > > Thanks forreply. > > > I understand that i can't simply use rpc call right inwidgetevent > > handler, > > but i want to separate this transport/business layer fromwidget. > > > Mywidgetsimply shows list of items of some class(Group) and provide > > control elements > > to manupulate them: edit, delete, add etc. > > > I am simply interested in a approach. maybe there is some standart way > > advices > > > For now - i provide two methods forwidgetclient - > > void add(Group) > > void onAdd/onSuccessAdd(Group) > > > maybe there is some more cultural way ? =) > > > On 2 дек, 13:37, gregor <[EMAIL PROTECTED]> wrote: > > > > Hi Relaxo, > > > > The simplest way is to make your RPC call from addBtn.onClick() using > > > an anonymous Callback where this callback's onSuccess(..) method adds > > > the new Group List<Group> groups and changes the view as required. > > > There may be reasons why this would not meet your requirements, but it > > > is not possible to say from your example, i.e. on the face of it you > > > do not need the controller interface. There isn't a single "right" way > > > to do asynchronous RPC - it is possible to over-engineer it and > > > equally it's possible to under-engineer it. > > > > If in fact your situation is more complicated than the example > > > (leading to a motivation for using this controller interface), > > > probably best to give some idea of the overall problem to get further > > > advice and options (of which there are several). > > > > regards > > > gregor > > > > On Dec 2, 8:15 am, raxelo <[EMAIL PROTECTED]> wrote: > > > > > First of all sorry for my english. > > > > > I want to write simple GUIwidgetthat will help me to add and delete > > > > some business groops > > > > like this. > > > > > public class GroupWidget extends Composite implements ClickListener { > > > > private Controller controller; > > > > private List<Group> groups; > > > > > public GroupWidget(List<Group> groups, Controller > > > > controller) { > > > > this.controller = controller; > > > > //buildwidgetskeleton > > > > //init structures > > > > } > > > > > public void onClick(Widgetsender) { > > > > if(sender == addBtn) { > > > > //creating group object using entered date > > > > such as name, picture etc... > > > > this.controller.add(group); > > > > } > > > > } > > > > > static interface Controller { > > > > Group add(Group group); > > > > void delete(Group group); > > > > } > > > > > } > > > > > but, i can't understand how it must work withasyncrequests > > > > > Application that will use thiswidgetwill useasyncrequests, so > > > > methods in controller must have void as > > > > a return type, but how can i notifywidgetthat group is created ? > > > > Should i add such methods towidget > > > > onAdd(Group newlyCreatedGroup) and > > > > onDelete() , that controller implementor have to call after receiving > > > > a response or maybe there is some > > > > approach or pattern. > > > > > Thanks a lot --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---