Hi
I am constructing custom SURequest object -- and need to access the post parameters during callback. How would you accesss the testParam callback parameter values. Ideally with something like: renderSaveRequestOn: html html anchor onClick: (html request callback: [ self updateModel: self testParamValue]; addParameter: 'testParam' -> 'abc'); with: 'SURequest example' What would #testParamValue need to implement? Thanks -- Edward Stow _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
> How would you accesss the testParam callback parameter values.
This is not how Seaside works. Try this: > html anchor > onClick: (html request > callback: [ self updateModel: testParamValue ]; > callback: [ :value | testParamValue := value ] value: 'abc'); > with: 'SURequest example' Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
On Tue, Apr 15, 2008 at 8:57 AM, Lukas Renggli <[hidden email]> wrote:
> > Try this: > > > > html anchor > > onClick: (html request > > callback: [ self updateModel: testParamValue ]; > > callback: [ :value | testParamValue := value ] value: 'abc'); > > with: 'SURequest example' > I think a little more explanation of my scenario is needed: I have a client side javascript application -- a google maps mashup with a number of overlays, that is manipulated entirely within the browser. The browser model can be serialized in json format with a function call eg: myModel.toJson() -- so what I want to end up with is a callback that returns the json data to my Seaside component. The basic questions is how to construct a the requests so to call some function eg toJson() in the browser and return the string generated by the function. Thanks -- Edward Stow _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
On Tue, Apr 15, 2008 at 9:25 AM, Edward Stow <[hidden email]> wrote:
> On Tue, Apr 15, 2008 at 8:57 AM, Lukas Renggli <[hidden email]> wrote: > > > > > Try this: > > > > > > > html anchor > > > onClick: (html request > > > callback: [ self updateModel: testParamValue ]; > > > callback: [ :value | testParamValue := value ] value: 'abc'); > > > with: 'SURequest example' > > > > I think a little more explanation of my scenario is needed: I have a > client side javascript application -- a google maps mashup with a > number of overlays, that is manipulated entirely within the browser. > The browser model can be serialized in json format with a function > call eg: > > myModel.toJson() -- so what I want to end up with is a callback that > returns the json data to my Seaside component. > > The basic questions is how to construct a the requests so to call some > function eg toJson() in the browser and return the string generated by > the function. I have been hacking around (in the pejorative sense) with WACallbackStream -- this works but is clearly not at all elegant. MyComponent>>processCallbackStream: aCallbackStream aCallbackStream request fields at: 'testParam' ifPresent: [:testParam | self updateModel: testParam ]. super processCallbackStream: aCallbackStream And in WACallbackStream>>request ^request -- Edward Stow _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
In reply to this post by Edward Stow
> > > 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. Lukas renggli -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
On Tue, Apr 15, 2008 at 3:58 PM, Lukas Renggli <[hidden email]> 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 _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
> So my final question is do you need the primary callback at all?
Not in your case, I suppose. Lukas -- Lukas Renggli http://www.lukas-renggli.ch _______________________________________________ seaside mailing list [hidden email] http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside |
Free forum by Nabble | Edit this page |