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
-~----------~----~----~----~------~----~------~--~---

Reply via email to