> > However in my app, the request is sometimes a POST with a body, > sometimes it's just a GET. I can see that the example will have to be > extended to handle such cases.
I'm doing the same exact thing, I'm still working to get it work with only one execute without actually having to add another parameter. So within an action class, I'll add the stuff that I need to send to the server here and then, when it reach de Dispatch call, if there's stuff to send, i'tll do a POST request with extra stuff, else, it'll do a GET request. It's the way it was originally designed, though without Gin and without command-pattern. > The pastie code demonstrates a unique class per object; which is > fundamentally the same as my first solution Actually, I make three extra classes client side for each action. Action/Reaction and the XML Unserializer for the type. Btw, it's less then what we have to do with gwt-dispatch, but once it's done, it's clear, concise and follow Better pratice guideline. Server side is a bit of a problem. Php doesn't have Generic and so, we have to select case wich class to build... Or I could do, one file per action and my client would call the appropriate file according to his action, so I don't have to select case it by exploring the xml file. Here's the problem for me. It takes a lot of work and it's suject to errors ! I'll have to find a nice and elegant proper way to do this. Any idea is welcome by the way. > Thank-you very much for taking the time to post this code. I will take the > time to study it. It's always a pleasure to share experiences. Thanks for your comments :) Christian > > On 08/29/2009 11:32 AM, Christian Goudreau wrote: > > First thing first, my implementation is for a server that don't have > > Servlet ! So gwt-dispatch wasn't the thing for me. I use it in another > > project, but for this one, I had to build a dispatch api from scratch. > > > > Si I decided to use XML for communication between PHP et my client and > > use Request Builder to retreive that XML. So, I CAN'T use real object ! > > By this you mean POJO's? > > > I have to "serialize" them with a custom class before sending them and > > then, on server side, deserialize them. There's a couple things to know > > when we use that type of communication. > > > > 1. Server Side is unaware of client side classes. So we can't use > > clients object or server object, that's why I have to "serialize" > > them in xml. I could use JSON btw. > > 2. I don't really need a "response" classe like in the model, since > > this classe is used to be send from the server to the client. > > Agreed. The GWT response is all that is needed. > > > 3. We have to do the work twice... That's shitty, but I had to make > > Products obejcts in PHP as well as in java. > > Agreed. That is a drawback, and a potential source of error. > > > 4. The only thing that is sent to the server by the client, is an URL > > ! The url to a specific php script that send back an XML reponse. > > So it's not generic, because it's always String that your parse > > back in XML ! > > However in my app, the request is sometimes a POST with a body, > sometimes it's just a GET. I can see that the example will have to be > extended to handle such cases. > > > So now, here's the complete meat in action. Hope you'll find something > > to use for yourself. > > http://pastie.org/598942 > > Yes. I will stare at it some more. There's no way I could get from your > first post to this one. Thank-you very much for your consideration. > > > So, in SearchProductPresenter I have the @inject is done here and I > > simply call (dispatcher.execute) the appropriate action(GetProductsName) > > and when I get the response(GotProductsName), I transform it from XML to > > the type I want. In service side, when the PHP script is called, it > > looks at the $_GET action and print out xml according to the argument. > > Agreed. That seems pretty standard. One thing I will add is stuff from > Hupa > (http://svn.apache.org/repos/asf/labs/hupa/src/main/java/org/apache/hupa/) > that handles authentication and authorization. > > > It's work in progress, I have a couple things to do to generalize the > > process on server side, and multiple type of objects actually doesn't > > work verry well (For Batching purpose), I chose XML over json for this > > very purpose. > > Yes, I can see that. In another application, I used XML (Perl <--> > JavaScript) for just that reason. It seems you are using Eclipse? I > found that the XML & DTD editors were quite helpful constructing complex > structures. > > The DTD was also input to an XML parsing/validating editor so that users > could construct source documents in XML. These documents were sent to > the client to be rendered as a questionnaire. The user responses were > added to the questionnaire and the resulting document POSTed to the > server for transformation via XSLTPROC into HTML. > > I can do the same thing to give the server some > > informations by adding content to the request, read it on server side > > and doing the action as said in my $_GET action string. > > Well, you're clearly doing exactly what I've been trying to do: take > lessons learned from gwt-dispatch and formulate into something that > works w/ RequestBuilder. I'm just not good enough at Java to understand > how to get There from Here. > > Thank-you very much for taking the time to post this code. I will take > the time to study it. > > > > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
