Seaside URL and FLEX HTTPService

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Seaside URL and FLEX HTTPService

Thelliez
Hi,

How would you encode a Seaside URL to be FLEX friendly? The URL was
obtained from a call to urlForAction.


You cannot send the URL with HTTPService in Flex
(http://www.bpurcell.org/blog/index.cfm?entry=1040&mode=entry).
But trying the mx:request proposed solution, a <_s> was transformed in
%5Fs. And I am not sure how you would pass the third value ("1") for a
URL like: http://myserver/seaside/myapp?_s=_DHqtxKBVBxRuX1o&_k=LvjV2ZDx&1

I tried creating an object
                        var o:Object =
URLUtil.stringToObject(urlParam, "&amp;");
                sField = o._s;
                kField = o._k;
                var params:Object = {};
                        params["_s"] = sField;
                        params["_k"] = kField;
                        params["1"] = "";

and then called a myHTTPService.send(params); but this still did not work.

I also tried to pass a fully encoded URL but then FLEX sends:
/seaside/myapp?_s=_DHqtxKBVBxRuX1o&amp;_k=LvjV2ZDx&amp;1

This does not work either becasuse of the &amp;

Has someone connected FLEX and Seaside through HTTPServer? Or other means?


Thanks,
Thierry
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside URL and FLEX HTTPService

Philippe Marschall
2008/9/27 Thierry Thelliez <[hidden email]>:

> Hi,
>
> How would you encode a Seaside URL to be FLEX friendly? The URL was
> obtained from a call to urlForAction.
>
>
> You cannot send the URL with HTTPService in Flex
> (http://www.bpurcell.org/blog/index.cfm?entry=1040&mode=entry).
> But trying the mx:request proposed solution, a <_s> was transformed in
> %5Fs. And I am not sure how you would pass the third value ("1") for a
> URL like: http://myserver/seaside/myapp?_s=_DHqtxKBVBxRuX1o&_k=LvjV2ZDx&1
>
> I tried creating an object
>                        var o:Object =
> URLUtil.stringToObject(urlParam, "&amp;");
>                sField = o._s;
>                kField = o._k;
>                var params:Object = {};
>                        params["_s"] = sField;
>                        params["_k"] = kField;
>                        params["1"] = "";
>
> and then called a myHTTPService.send(params); but this still did not work.
>
> I also tried to pass a fully encoded URL but then FLEX sends:
> /seaside/myapp?_s=_DHqtxKBVBxRuX1o&amp;_k=LvjV2ZDx&amp;1
>
> This does not work either becasuse of the &amp;
>
> Has someone connected FLEX and Seaside through HTTPServer? Or other means?

If you provide some more context of what actually you're trying to
achieve and what the problems are we non-Flex guys might be able to
help you.

Cheers
Philippe
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside URL and FLEX HTTPService

Thelliez
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);"
    />

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.

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).

Has anyone done it? How?
Thanks,
Thierry
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside URL and FLEX HTTPService

John McKeon
I would not claim to even have much knowledge of HTML :)
It appears that you are trying to make your seaside app a Flex service
or something like that. This would be a separate app that ANY page could
call and get an expected result. As such, the _s and _k parameters are
meaning less as they only pertain to an active session of a seaside
application.
I.e. when I want to "surf" to my seaside created web page, I do not
enter in my browser http://myurl/_sG5t7urxy;_ketc.. i just enter
http://myurl right?
So your service must accept requests with parameters that YOUR SERVICE
needs in order to return an expected response.Like
http://myurl/flexstuff/flexsvc1 and /flexstuff/flexsvc2

This requires more than a typical seaside app I think. Look at the
classes in Seaside-Request Handler category. You may need to subclass
WARequestHandler or WAEntryPoint.

This is what I get when I look at what bpurcell had to say.

Of course, I could have absolutley no idea what I am talking about. In
any event I do hope this helps.

Best regards,
Johnny

Thierry Thelliez wrote:

> 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);"
>     />
>
> 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.
>
> 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).
>
> Has anyone done it? How?
> Thanks,
> Thierry
> _______________________________________________
> seaside mailing list
> [hidden email]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
>  

_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside URL and FLEX HTTPService

Thelliez
> It appears that you are trying to make your seaside app a Flex service or
> something like that.

For now I am just trying to display some rows in a FLEX DataGrid
componen. Nothing fancy, just a proof concept.

> As such, the _s and _k parameters are meaning
> less as they only pertain to an active session of a seaside application.

I do need the _s and _k as I would like the returned XML to be
session/user specific (dynamically generated on the Seaside side).

The problem I have is the encoding of the Seaside style URL. The
underscores and the third parameters are breaking the FLEX httpservice
XML based requests.

I saw some posts in 2007 about Seaside and FLEX. But I cannot tell if
someone has successfully done it or not.

Cheers,
Thierry
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: Seaside URL and FLEX HTTPService

Philippe Marschall
In reply to this post by Thelliez
2008/9/28, Thierry Thelliez <[hidden email]>:

> 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
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside