[Glass] Problem assigning to temp vars from Seaside callbacks?
Mariano Martinez Peck
marianopeck at gmail.com
Tue Jan 28 07:26:54 PST 2014
On Tue, Jan 28, 2014 at 5:36 AM, Johan Brichau <johan at yesplan.be> wrote:
> Hey Mariano,
>
> If you want to transfer values between callbacks (closures) in Seaside on
> Gemstone, you need to put the value in a valueholder object instead of
> assigning to method temporaries. Otherwise, you experience exactly what you
> see. That means, for example:
>
> | valueholder|
> valueholder := ValueHolder new.
>
> html jQuery ajax
> callback: [:v | valueholder value: v];
> script: [:s | self doSomethingWith: valueholder value]
>
> You can use anything you like as a valueholder: Association, Array, Set,
> ... whatever. As long as you are not directly assigning to the temporary
> var.
> There is also code demonstrating this in the JQueryUI Autocomplete code of
> Seaside (gemstone version) [2].
>
> I referred to that issue in this mail [1] but it was a bit condensed I
> guess.
>
>
Thanks Johan!!!! That was exactly the problem and using a ValueHolder
solved the problem.
I didn't remember directly you comment in [1] but somewhere deep in my
brain was it because I knew it was related to callbacks and temps ;)
BTW..... do you know if there is a slime rule or something to check this? I
am sure I have many other places like this...
> cheers
> Johan
>
> [1]
> http://forum.world.st/Glass-Basic-questions-regarding-GemBuilder-for-Smalltalk-GemTools-and-tODE-tp4711463p4711987.html
> [2]
> https://github.com/glassdb/Seaside31/blob/gemstone3.1/repository/JQuery-UI.package/JQAutocomplete.class/instance/search.labels.callback..st
>
> On 27 Jan 2014, at 22:10, Mariano Martinez Peck <marianopeck at gmail.com>
> wrote:
>
> > Hi guys,
> >
> > I am starting to see strange problems that happen only in GemStone but
> work correctly in Pharo.
> >
> > I have a menu action that looks like this:
> >
> >
> > (aWebAppBrowser actionType new
> > context: #contextMenu;
> > argumentTypes:
> > {Object.
> > Collection.
> > (aWebAppBrowser class)};
> > label: 'SIXX Import and Replace DB';
> > block: [ :cls :collection :app |
> > | list |
> > (app activeModelReport isKindOf:
> MAReport)
> > ifTrue: [ | filenameForm
> filename |
> > list := app
> objectsForActions. "filtered and sorted"
> > filenameForm :=
> MyRenderedBlockFormDialog new.
> > filenameForm
> >
> buttonsAndCallbacksList:
> >
> {(#import -> [ filenameForm answer: true ]).
> >
> (#cancel -> [ filenameForm answer: false ])};
> >
> renderingBlock: [ :html |
> >
> html text: 'Import filename prefix'.
> >
> html textInput
> >
> size: 100;
> >
> callback: [ :value | self halt. filename := value trimBoth ];
> >
> value: 'filename_here' ];
> > addForm.
> > (app call:
> filenameForm)
> > ifTrue: [
> >
> self halt.
> >
> > ]
> > ]]
> >
> >
> > That action has the closure which is compiled once at the beginning of
> the app and then valued whenever clicked. Now...that closure creates an
> instance of MyRenderedBlockFormDialog which has a simple input for a
> filename. When I click on "import" the callback of the text input is
> invoked correctly. Soo....'filename' temp receives the value correctly.
> However, after the call to such a component (app call: filenameForm), (the
> "self halt" inside the ifTrue)... the temp var 'filename' has a nil!!!!
> Any ideas why I get a nil here instead of the real value?
> > Same code and same test in Pharo does work correctly.
> >
> > Thanks in advance,
> >
> > --
> > Mariano
> > http://marianopeck.wordpress.com
> > _______________________________________________
> > Glass mailing list
> > Glass at lists.gemtalksystems.com
> > http://lists.gemtalksystems.com/mailman/listinfo/glass
>
>
--
Mariano
http://marianopeck.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.gemtalksystems.com/mailman/private/glass/attachments/20140128/c3eaad08/attachment.html>
More information about the Glass
mailing list