[Seaside] Accessing SURequest / SUAjax post parameters
Edward Stow
ed.stow at gmail.com
Tue Apr 15 08:00:35 UTC 2008
On Tue, Apr 15, 2008 at 3:58 PM, Lukas Renggli <renggli at gmail.com> wrote:
> > > > html anchor
> > > > onClick: (html request
> > > > callback: [ self updateModel: testParamValue ];
> > > > callback: [ :value | testParamValue := value ] value: 'abc');
> > > > with: 'SURequest example'
>
> Why doesn't this code work?
>
> I only notice now that you are using a #request, so you can even make
> it simpler:
>
> html request callback: [ :value | self updateModel: value ] value: 'abc'
>
>
> > myModel.toJson() -- so what I want to end up with is a callback that
> > returns the json data to my Seaside component.
>
> The #callback:value:'s first argument is the callback block with the
> value, the second argument is the JSON data (in this case a string)
> that is serialized on the browser side and brought to the server side.
> See the method comment for details.
I read the comment (copied below) and was a little confused:
SUAjax>>callback: aBlock value: anObject
"Register aBlock as a secondary callback. anObject is interpreted as
JavaScript on the client-side, the result will be sent back to the
server and passed into aBlock. Multiple secondary callbacks can be
defined with one receiver."
I took this to (incorrectly) mean that anObject is serialized to a
json format, and is included as a string in the post parameters. This
does work:
str := SUStream new nextPutAll: 'myMap.toJson()'.
html anchor
onClick: (html request
callback: [ :value | self updateModel: value ] value: str );
with: 'SURequest example'
So my final question is do you need the primary callback at all?
Thanks
--
Edward Stow
More information about the seaside
mailing list