User input and component state update via GET

4 messages Options
Embed this post
Permalink
Michael Forster-3

User input and component state update via GET

Reply Threaded More More options
Print post
Permalink
Hi,

I'm using squeak-web 3.10.2-7179 image, with seaside 2.8a-1r.572.

I'm writing an application that must be accessed via handheld
scanners.  The scanners run an extended version of Internet Explorer
that provides an HTML meta tag to capture a scanned barcode and submit
it via a GET request.  I've prototyped this using a raw Commanche form
renderer and handler, but there is a great deal more interactivity
required, and I would really like to take advantage of Seaside.

I can generate the required meta tag, as shown below:

    updateRoot: anHtmlRoot
        | meta |
        super updateRoot: anHtmlRoot.
        meta := anHtmlRoot meta.
        meta responseHeaderName: 'scannernavigate'.
        meta content: anHtmlRoot context actionUrl asString,
'&barcodeno=%s&Source=%s&Type=%s&Time=%s&Length=%s'

However, because I retain the _s and _k parameters, I can't use
#initialRequest to parse the 'barcodeno' parameter from the GET
request.  This isn't quite the same as the problems that Ramon Leon
addressed in his 'Clean URLs' and 'Stateless Sitemap' articles.
Essentially, I need a regular session/continuation-based Seaside app,
with a couple of components that capture input via GET, but which
still allow a call/answer approach.

After hunting around the list archives and the Seaside sources, I'm
starting to think that I need to recreate the notion of separate forms
and handlers atop Seaside, using URL redirects to glue them together.
Am I barking up the wrong tree here?

Thanks in advance for any advice!

Mike

--
Michael J. Forster <[hidden email]>
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Lukas Renggli

Re: User input and component state update via GET

Reply Threaded More More options
Print post
Permalink
> However, because I retain the _s and _k parameters, I can't use
> #initialRequest to parse the 'barcodeno' parameter from the GET
> request.  This isn't quite the same as the problems that Ramon Leon
> addressed in his 'Clean URLs' and 'Stateless Sitemap' articles.
> Essentially, I need a regular session/continuation-based Seaside app,
> with a couple of components that capture input via GET, but which
> still allow a call/answer approach.

Have a look at the implementation of WATask>>updateRoot:. Instead of
doing a redirect you just create your meta-tag. And you replace the
callback block with the code that handles the request.

I would try something along the following lines:

   updateRoot: aHtmlRoot
        | callbacks url |
        callbacks := WACallbackRegistry context: aHtmlRoot context owner: self.
        url := aHtmlRoot context actionUrl withParameter: (callbacks
registerActionCallback: [ self metaHandler ]).
        aHtmlRoot
            responseHeaderName: 'scannernavigate';
            content: url asString ,
'&barcodeno=%s&Source=%s&Type=%s&Time=%s&Length=%s'

   metaHandler
        | request id |
        request := self session currentRequest.
        id := request at: 'barcodeno' ifAbsent: [ ^ self inform: 'Error' ].
        self call: (BCProductView on: id)

Does that help?

Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Michael Forster-3

Re: User input and component state update via GET

Reply Threaded More More options
Print post
Permalink
On Mon, Jun 29, 2009 at 12:04 PM, Lukas Renggli<[hidden email]> wrote:
[...]
> Have a look at the implementation of WATask>>updateRoot:. Instead of
> doing a redirect you just create your meta-tag. And you replace the
> callback block with the code that handles the request.
>
> I would try something along the following lines:
[...]

Thank you, Lukas!  I was wondering about registering a callback, but
I'm still too new to Seaside to avoid the dead-ends, and time is
short.

I will try that and let you know.

Cheers,

Mike
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Michael Forster-3

Re: User input and component state update via GET

Reply Threaded More More options
Print post
Permalink
On Mon, Jun 29, 2009 at 12:23 PM, Michael Forster<[hidden email]> wrote:

> On Mon, Jun 29, 2009 at 12:04 PM, Lukas Renggli<[hidden email]> wrote:
> [...]
>> Have a look at the implementation of WATask>>updateRoot:. Instead of
>> doing a redirect you just create your meta-tag. And you replace the
>> callback block with the code that handles the request.
>>
>> I would try something along the following lines:
> [...]
>
> Thank you, Lukas!  I was wondering about registering a callback, but
> I'm still too new to Seaside to avoid the dead-ends, and time is
> short.
>
> I will try that and let you know.


Yes, that worked, perfectly.

Thanks again,

Mike
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside