[Seaside] Seaside URL and FLEX HTTPService

Philippe Marschall philippe.marschall at gmail.com
Tue Sep 30 05:28:28 UTC 2008


2008/9/28, Thierry Thelliez <thierry.thelliez.tech at gmail.com>:
> I would not claim much knowledge about FLEX. There might be a better
> way to do it...
>
> I am just trying to prototype a web page with part of its content
> displayed through FLEX. Seaside would generate the HTML page contening
> a call to the SWF file (generated from compiling the FLEX code). The
> FLEX component would then call back Seaside to get some XML formatted
> data and display that in a DataGrid.
>
> FLEX can call a web service in one call. For example
> (from http://www.adobe.com/devnet/flex/quickstart/httpservice/)
>
>    <mx:HTTPService
>         id="photoService"
>         url="http://api.flickr.com/services/feeds/photos_public.gne"
>         resultFormat="e4x"
>         result="photoResultHandler(event);"
>         fault="photoFaultHandler(event);"
>     />
>
> The first problem is that you cannot pass the URL parameters in the URL
> field.
>
> You could not send:
>    <mx:HTTPService
>         id="photoService"
>         url="http://myServer/seaside/myApp?_s=68pqfS&_k=SW7A&1"
>         resultFormat="e4x"
>         result="photoResultHandler(event);"
>         fault="photoFaultHandler(event);"
>     />

If that's XML you absolutely have to have &amp; instead of &. If they
don't translate this to & then they are buggy.

> They have an XML formatting option using mx:request as described in:
> http://www.bpurcell.org/blog/index.cfm?entry=1040&mode=entry
>
> <mx:HTTPService url="{myURL}" id="myHTTPData" method="GET"
> resultFormat="object">
>   <mx:request>
>   <mode>{mode}</mode>
>   <mode2>{mode2}</mode2>
>   <catid>{catid}</catid>
>  </mx:request>
>
>
> But translated to Seaside does not work (assuming that sField and
> kField are filled with the right values):
> <mx:HTTPService url="http://myServer/seaside/myApp" id="myHTTPData"
> method="GET" resultFormat="object">
>   <mx:request>
>   <_s>{sField}</_s>
>   <_k>{kField}</_k>
>   <1></1>
>  </mx:request>
> </mx:HTTPService>
>
> The <1> is not allowed in XML and the <_s> becomes a %5Fs.

Doesn't the server decode this back to _s? What dialect, server and
Seaside are you running?

> I tried other options but none are friendly to the usage of
> underscores and/or the value-less parameters (the last '&1' in the
> url).

You are returning session and user specific XML, right? In general the
way to go would be a custom request handler / entry point. The problem
is that they don't know jack about sessions. In your case it would be
even worse, you'd also have to set up the session lock. You can do
this but it is messy.

So in your case what looks like the way to go is some sort of virtual
URI mapping. E.g. map

/seaside/myApp?_s=x&_k=y&z

to

/seaside/myAppForFlex/x/y/z

and back.

The first part should not be so hard, given that you already have the
action url.

Now for the second part you need to reimplement that is known as a
forward request in Java EE. Or use Apache mod_rewrite magic.

1. you still need to implement a request handler / entry point
2. you need to parse the url and set up a new request
3. get the dispatcher (or the myApp application) and send it
#handleRequest: with you new request object

I should have implemented forward request in Seaside 2.9, I knew it.

Cheers
Philippe


More information about the seaside mailing list