Re: script: [...] value parameter

Johan Brichau <[email protected]> Mon, 24 Oct 2022 09:08:14 +0200
Newsgroups gmane.comp.lang.smalltalk.squeak.seaside
Message-ID <[email protected]>
--===============3788237888823431166==
Content-Type: multipart/alternative;
	boundary="Apple-Mail=_DCC1DE69-9C09-4DCC-904B-3F147FAD260B"


--Apple-Mail=_DCC1DE69-9C09-4DCC-904B-3F147FAD260B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/plain;
	charset=us-ascii

I copy/paste my response on the Discord channel:

An ajax request with Seaside JQuery can combine multiple secondary =
callbacks and a single primary callback. You can find out which are =
which in the method comments on JQAjax. In short: a primary callback is =
a response-generating callback, while secondary callbacks are callbacks =
that pass values from the client to the server.=20
As such, you can construct what you want already as follows:
| value |
html jQuery ajax=20
   callback: [ :v | value :=3D v ] value: (html jQuery this propertyAt: =
'id');
   script: [ :s | ...use value in the generation of the script... ]




[9:40 AM]
Also, take a look at passengers if you want to store objects and =
retrieve them by id. Seaside has this mechanism built-in for you:
| value |
html button
   passenger: self;
   onClick: (html jQuery ajax=20
       callback: [ :v | value :=3D v ] passenger: (html jQuery this);


> On 21 Oct 2022, at 19:48, Bob Nemec <[email protected]> wrote:
>=20
> Cross posted from Seaside Discord channel...
>=20
> I would like to have an 'html ajax script: [...]' method that has a =
callback:value: pattern.=20
>=20
> Something like...=20
>     html ajax script: [:script :value | ...] value: (html jQuery this =
propertyAt: 'id')=20
>=20
> Then in the script block 'value' would get the id of 'this', which in =
an ajax callback is undefined.=20
> This would allow server code to use browser information to build the =
script.=20
>=20
> Anyone done this?
>=20
>=20
> Bob Nemec
>=20
> _______________________________________________
> seaside mailing list
> [email protected]
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside


--Apple-Mail=_DCC1DE69-9C09-4DCC-904B-3F147FAD260B
Content-Transfer-Encoding: quoted-printable
Content-Type: text/html;
	charset=us-ascii

<html><head><meta http-equiv=3D"Content-Type" content=3D"text/html; =
charset=3Dus-ascii"></head><body style=3D"word-wrap: break-word; =
-webkit-nbsp-mode: space; line-break: after-white-space;" class=3D"">I =
copy/paste my response on the Discord channel:<div class=3D""><br =
class=3D""></div><div class=3D""><ol class=3D"scrollerInner-2PPAp2" =
aria-label=3D"Messages in seaside" role=3D"list" =
data-list-id=3D"chat-messages" tabindex=3D"0" style=3D"margin: 0px; =
padding: 0px; border: 0px; font-family: Whitney, &quot;Helvetica =
Neue&quot;, Helvetica, Arial, sans-serif; font-size: 16px; =
vertical-align: baseline; list-style: none; min-height: 0px; =
font-variant-ligatures: normal; orphans: 2; widows: 2; background-color: =
rgb(255, 255, 255); text-decoration-thickness: initial;"><li =
id=3D"chat-messages-1033645149160480829" class=3D"messageListItem-ZZ7v6g" =
aria-setsize=3D"-1" style=3D"margin: 0px; padding: 0px; border: 0px; =
font-style: inherit; font-family: inherit; vertical-align: baseline; =
outline: none;"><div class=3D"groupStart-3Mlgv1 hasReply-2Cr4KE =
wrapper-30-Nkg message-2CShn3 zalgo-26OfGz cozyMessage-1DWF9U =
cozy-VmLDNB" role=3D"article" =
data-list-item-id=3D"chat-messages___chat-messages-1033645149160480829" =
tabindex=3D"-1" aria-setsize=3D"-1" aria-roledescription=3D"Message" =
aria-labelledby=3D"message-reply-context-1033645149160480829 uid_1 =
message-content-1033645149160480829 uid_2 =
message-timestamp-1033645149160480829" style=3D"margin: 1.0625rem 0px =
0px; padding-top: 0.125rem; padding-bottom: 0.125rem; padding-left: =
72px; border: 0px; font-style: inherit; font-family: inherit; =
vertical-align: baseline; outline: 0px; position: relative; =
overflow-wrap: break-word; -webkit-box-flex: 0; flex: 0 0 auto; =
min-height: 2.75rem; background-color: var(--background-message-hover); =
padding-right: 48px !important;"><div class=3D"contents-2MsGLg" =
style=3D"margin: 0px; padding: 0px; border: 0px; font-style: inherit; =
font-family: inherit; vertical-align: baseline; outline: 0px; position: =
static;"><div id=3D"message-content-1033645149160480829" =
class=3D"markup-eYLPri messageContent-2t3eCI" style=3D"margin: 0px 0px =
0px -72px; padding: 0px 0px 0px 72px; border: 0px; font-style: inherit; =
font-family: inherit; font-size: 1rem; vertical-align: baseline; =
outline: 0px; line-height: 1.375rem; white-space: break-spaces; =
overflow-wrap: break-word; color: var(--text-normal); position: =
relative; overflow: hidden;">An ajax request with Seaside JQuery can =
combine multiple secondary callbacks and a single primary callback. You =
can find out which are which in the method comments on JQAjax. In short: =
a primary callback is a response-generating callback, while secondary =
callbacks are callbacks that pass values from the client to the server.=20=

As such, you can construct what you want already as follows:
<pre style=3D"margin-top: 6px; margin-bottom: 0px; padding: 0px; border: =
0px; font-style: inherit; font-family: Consolas, &quot;Andale Mono =
WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, =
&quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, =
&quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, =
&quot;Nimbus Mono L&quot;, Monaco, &quot;Courier New&quot;, Courier, =
monospace; font-size: 0.75rem; vertical-align: baseline; border-radius: =
4px; line-height: 1rem; white-space: pre-wrap; background-clip: =
border-box; box-sizing: border-box; max-width: 90%;" class=3D""><code =
class=3D"hljs scrollbarGhostHairline-2LpzZ9 scrollbar-3vVt8d" =
style=3D"margin: 0px; padding: 0.5em; border: 1px solid =
var(--background-tertiary); font-style: inherit; font-family: Consolas, =
&quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida =
Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans =
Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation =
Mono&quot;, &quot;Nimbus Mono L&quot;, Monaco, &quot;Courier New&quot;, =
Courier, monospace; font-size: 0.875rem; vertical-align: baseline; =
line-height: 1.125rem; display: block; overflow-x: auto; border-radius: =
4px; color: var(--header-secondary); background: =
var(--background-secondary);">| value |
html jQuery ajax=20
   callback: [ :v | value :=3D v ] value: (html jQuery this propertyAt: =
'id');
   script: [ :s | ...use value in the generation of the script... =
]</code></pre></div></div><div class=3D"buttonContainer-1502pf" =
style=3D"margin: 0px; padding: 0px; border: 0px; font-style: inherit; =
font-family: inherit; vertical-align: baseline; outline: 0px; position: =
absolute; top: 0px; right: 0px;"><div class=3D"buttons-3dF5Kd =
container-2gUZhU isHeader-2bbX-L" role=3D"group" aria-label=3D"Message =
Actions" style=3D"margin: 0px; padding: 0px 14px 0px 32px; border: 0px; =
font-style: inherit; font-family: inherit; vertical-align: baseline; =
outline: 0px; opacity: 1; pointer-events: auto; position: absolute; =
right: 0px; z-index: 1; top: -16px;"><div class=3D"wrapper-2vIMkT" =
style=3D"margin: 0px; padding: 0px; border: 0px; font-style: inherit; =
font-family: inherit; vertical-align: baseline; outline: 0px; =
background-color: var(--background-primary); box-shadow: =
var(--elevation-stroke); display: grid; grid-auto-flow: column; =
box-sizing: border-box; height: 32px; border-radius: 4px; =
-webkit-box-align: center; align-items: center; -webkit-box-pack: start; =
justify-content: flex-start; transition: box-shadow 0.1s ease-out 0s, =
-webkit-box-shadow 0.1s ease-out 0s; position: relative; overflow: =
hidden;"><div class=3D"button-3bklZh" aria-label=3D"Add Reaction" =
aria-expanded=3D"false" role=3D"button" tabindex=3D"0" style=3D"margin: =
0px; padding: 4px; border: 0px; font-style: inherit; font-family: =
inherit; vertical-align: baseline; outline: 0px; display: flex; =
-webkit-box-align: center; align-items: center; -webkit-box-pack: =
center; justify-content: center; height: 24px; min-width: 24px; =
-webkit-box-flex: 0; flex: 0 0 auto; color: var(--interactive-normal); =
cursor: pointer; position: relative;"><svg class=3D"icon-1zidb7" =
aria-hidden=3D"true" role=3D"img" width=3D"24" height=3D"24" viewBox=3D"0 =
0 24 24"><path fill=3D"currentColor" fill-rule=3D"evenodd" =
clip-rule=3D"evenodd" d=3D"M12.2512 2.00309C12.1677 2.00104 12.084 2 12 =
2C6.477 2 2 6.477 2 12C2 17.522 6.477 22 12 22C17.523 22 22 17.522 22 =
12C22 11.916 21.999 11.8323 21.9969 11.7488C21.3586 11.9128 20.6895 12 =
20 12C15.5817 12 12 8.41828 12 4C12 3.31052 12.0872 2.6414 12.2512 =
2.00309ZM10 8C10 6.896 9.104 6 8 6C6.896 6 6 6.896 6 8C6 9.105 6.896 10 =
8 10C9.104 10 10 9.105 10 8ZM12 19C15.14 19 18 16.617 18 14V13H6V14C6 =
16.617 8.86 19 12 19Z"></path><path d=3D"M21 =
3V0H19V3H16V5H19V8H21V5H24V3H21Z" =
fill=3D"currentColor"></path></svg></div><div class=3D"button-3bklZh" =
aria-label=3D"Edit" role=3D"button" tabindex=3D"0" style=3D"margin: 0px; =
padding: 4px; border: 0px; font-style: inherit; font-family: inherit; =
vertical-align: baseline; outline: 0px; display: flex; =
-webkit-box-align: center; align-items: center; -webkit-box-pack: =
center; justify-content: center; height: 24px; min-width: 24px; =
-webkit-box-flex: 0; flex: 0 0 auto; color: var(--interactive-normal); =
cursor: pointer; position: relative;"><svg class=3D"icon-1zidb7" =
aria-hidden=3D"true" role=3D"img" width=3D"16" height=3D"16" viewBox=3D"0 =
0 24 24"><path fill-rule=3D"evenodd" clip-rule=3D"evenodd" d=3D"M19.2929 =
9.8299L19.9409 9.18278C21.353 7.77064 21.353 5.47197 19.9409 =
4.05892C18.5287 2.64678 16.2292 2.64678 14.817 4.05892L14.1699 =
4.70694L19.2929 9.8299ZM12.8962 5.97688L5.18469 13.6906L10.3085 =
18.813L18.0201 11.0992L12.8962 5.97688ZM4.11851 20.9704L8.75906 =
19.8112L4.18692 15.239L3.02678 19.8796C2.95028 20.1856 3.04028 20.5105 =
3.26349 20.7337C3.48669 20.9569 3.8116 21.046 4.11851 20.9704Z" =
fill=3D"currentColor"></path></svg></div><div class=3D"button-3bklZh" =
aria-label=3D"Create Thread" role=3D"button" tabindex=3D"0" =
style=3D"margin: 0px; padding: 4px; border: 0px; font-style: inherit; =
font-family: inherit; vertical-align: baseline; outline: 0px; display: =
flex; -webkit-box-align: center; align-items: center; -webkit-box-pack: =
center; justify-content: center; height: 24px; min-width: 24px; =
-webkit-box-flex: 0; flex: 0 0 auto; color: var(--interactive-normal); =
cursor: pointer; position: relative;"><svg class=3D"icon-1zidb7" =
aria-hidden=3D"true" role=3D"img" width=3D"24" height=3D"24" viewBox=3D"0 =
0 24 24" fill=3D"none"><path fill=3D"currentColor" d=3D"M5.43309 =
21C5.35842 21 5.30189 20.9325 5.31494 20.859L5.99991 17H2.14274C2.06819 =
17 2.01168 16.9327 2.02453 16.8593L2.33253 15.0993C2.34258 15.0419 =
2.39244 15 2.45074 15H6.34991L7.40991 9H3.55274C3.47819 9 3.42168 =
8.93274 3.43453 8.85931L3.74253 7.09931C3.75258 7.04189 3.80244 7 =
3.86074 7H7.75991L8.45234 3.09903C8.46251 3.04174 8.51231 3 8.57049 =
3H10.3267C10.4014 3 10.4579 3.06746 10.4449 3.14097L9.75991 =
7H15.7599L16.4523 3.09903C16.4625 3.04174 16.5123 3 16.5705 =
3H18.3267C18.4014 3 18.4579 3.06746 18.4449 3.14097L17.7599 =
7H21.6171C21.6916 7 21.7481 7.06725 21.7353 7.14069L21.4273 =
8.90069C21.4172 8.95811 21.3674 9 21.3091 9H17.4099L17.0495 =
11.04H15.05L15.4104 9H9.41035L8.35035 15H10.5599V17H7.99991L7.30749 =
20.901C7.29732 20.9583 7.24752 21 7.18934 21H5.43309Z"></path><path =
fill=3D"currentColor" d=3D"M13.4399 12.96C12.9097 12.96 12.4799 13.3898 =
12.4799 13.92V20.2213C12.4799 20.7515 12.9097 21.1813 13.4399 =
21.1813H14.3999C14.5325 21.1813 14.6399 21.2887 14.6399 =
21.4213V23.4597C14.6399 23.6677 14.8865 23.7773 15.0408 23.6378L17.4858 =
21.4289C17.6622 21.2695 17.8916 21.1813 18.1294 21.1813H22.5599C23.0901 =
21.1813 23.5199 20.7515 23.5199 20.2213V13.92C23.5199 13.3898 23.0901 =
12.96 22.5599 12.96H13.4399Z"></path></svg></div><div =
class=3D"button-3bklZh" aria-label=3D"More" aria-expanded=3D"false" =
role=3D"button" tabindex=3D"0" style=3D"margin: 0px; padding: 4px; =
border: 0px; font-style: inherit; font-family: inherit; vertical-align: =
baseline; outline: 0px; display: flex; -webkit-box-align: center; =
align-items: center; -webkit-box-pack: center; justify-content: center; =
height: 24px; min-width: 24px; -webkit-box-flex: 0; flex: 0 0 auto; =
color: var(--interactive-normal); cursor: pointer; position: =
relative;"><svg class=3D"icon-1zidb7" aria-hidden=3D"true" role=3D"img" =
width=3D"24" height=3D"24" viewBox=3D"0 0 24 24"><path =
fill=3D"currentColor" fill-rule=3D"evenodd" clip-rule=3D"evenodd" d=3D"M7 =
12.001C7 10.8964 6.10457 10.001 5 10.001C3.89543 10.001 3 10.8964 3 =
12.001C3 13.1055 3.89543 14.001 5 14.001C6.10457 14.001 7 13.1055 7 =
12.001ZM14 12.001C14 10.8964 13.1046 10.001 12 10.001C10.8954 10.001 10 =
10.8964 10 12.001C10 13.1055 10.8954 14.001 12 14.001C13.1046 14.001 14 =
13.1055 14 12.001ZM19 10.001C20.1046 10.001 21 10.8964 21 12.001C21 =
13.1055 20.1046 14.001 19 14.001C17.8954 14.001 17 13.1055 17 12.001C17 =
10.8964 17.8954 10.001 19 =
10.001Z"></path></svg></div></div></div></div></div></li><li =
id=3D"chat-messages-1033646070099623978" class=3D"messageListItem-ZZ7v6g" =
aria-setsize=3D"-1" style=3D"margin: 0px; padding: 0px; border: 0px; =
font-style: inherit; font-family: inherit; vertical-align: baseline; =
outline: none;"><div class=3D"wrapper-30-Nkg cozyMessage-1DWF9U =
cozy-VmLDNB zalgo-26OfGz message-2CShn3" role=3D"article" =
data-list-item-id=3D"chat-messages___chat-messages-1033646070099623978" =
tabindex=3D"-1" aria-setsize=3D"-1" aria-roledescription=3D"Message" =
aria-labelledby=3D"message-username-1033645149160480829 uid_1 =
message-content-1033646070099623978 uid_2 =
message-timestamp-1033646070099623978" style=3D"margin: 0px; =
padding-top: 0.125rem; padding-bottom: 0.125rem; padding-left: 72px; =
border: 0px; font-style: inherit; font-family: inherit; vertical-align: =
baseline; outline: 0px; position: relative; overflow-wrap: break-word; =
-webkit-box-flex: 0; flex: 0 0 auto; min-height: 1.375rem; =
padding-right: 48px !important;"><div class=3D"contents-2MsGLg" =
style=3D"margin: 0px; padding: 0px; border: 0px; font-style: inherit; =
font-family: inherit; vertical-align: baseline; outline: 0px; position: =
static;"><span class=3D"timestamp-p1Df1m latin24CompactTimeStamp-2pXUBq =
timestampVisibleOnHover-9PEuZS alt-1dvXnH" style=3D"margin: 0px 0.25rem =
0px 0px; padding: 0px; border: 0px; font-style: inherit; font-family: =
inherit; font-size: 0.6875rem; vertical-align: baseline; outline: 0px; =
display: inline-block; height: 1.375rem; cursor: default; =
pointer-events: auto; opacity: 0; width: 56px; line-height: 1.375rem; =
color: var(--text-muted); text-align: right; position: absolute; left: =
0px; z-index: 1;"><time aria-label=3D"Today at 9:40 AM" =
id=3D"message-timestamp-1033646070099623978" =
datetime=3D"2022-10-23T07:40:27.327Z" class=3D""><span =
class=3D"separator-AebOhG" aria-hidden=3D"true" style=3D"position: =
absolute; opacity: 0; width: 0px; display: inline-block;">[</span>9:40 =
AM<span class=3D"separator-AebOhG" aria-hidden=3D"true" style=3D"position:=
 absolute; opacity: 0; width: 0px; display: =
inline-block;">]</span></time></span><div =
id=3D"message-content-1033646070099623978" class=3D"markup-eYLPri =
messageContent-2t3eCI" style=3D"margin: 0px 0px 0px -72px; padding: 0px =
0px 0px 72px; border: 0px; font-style: inherit; font-family: inherit; =
font-size: 1rem; vertical-align: baseline; outline: 0px; line-height: =
1.375rem; white-space: break-spaces; overflow-wrap: break-word; color: =
var(--text-normal); position: relative; overflow: hidden;">Also, take a =
look at passengers if you want to store objects and retrieve them by id. =
Seaside has this mechanism built-in for you:
<pre style=3D"margin-top: 6px; margin-bottom: 0px; padding: 0px; border: =
0px; font-style: inherit; font-family: Consolas, &quot;Andale Mono =
WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida Console&quot;, =
&quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans Mono&quot;, =
&quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation Mono&quot;, =
&quot;Nimbus Mono L&quot;, Monaco, &quot;Courier New&quot;, Courier, =
monospace; font-size: 0.75rem; vertical-align: baseline; border-radius: =
4px; line-height: 1rem; white-space: pre-wrap; background-clip: =
border-box; box-sizing: border-box; max-width: 90%;" class=3D""><code =
class=3D"hljs scrollbarGhostHairline-2LpzZ9 scrollbar-3vVt8d" =
style=3D"margin: 0px; padding: 0.5em; border: 1px solid =
var(--background-tertiary); font-style: inherit; font-family: Consolas, =
&quot;Andale Mono WT&quot;, &quot;Andale Mono&quot;, &quot;Lucida =
Console&quot;, &quot;Lucida Sans Typewriter&quot;, &quot;DejaVu Sans =
Mono&quot;, &quot;Bitstream Vera Sans Mono&quot;, &quot;Liberation =
Mono&quot;, &quot;Nimbus Mono L&quot;, Monaco, &quot;Courier New&quot;, =
Courier, monospace; font-size: 0.875rem; vertical-align: baseline; =
line-height: 1.125rem; display: block; overflow-x: auto; border-radius: =
4px; color: var(--header-secondary); background: =
var(--background-secondary);">| value |
html button
   passenger: self;
   onClick: (html jQuery ajax=20
       callback: [ :v | value :=3D v ] passenger: (html jQuery =
this);</code></pre></div></div></div></li></ol><div class=3D""><br =
class=3D""></div><div><br class=3D""><blockquote type=3D"cite" =
class=3D""><div class=3D"">On 21 Oct 2022, at 19:48, Bob Nemec &lt;<a =
href=3D"mailto:[email protected]" class=3D"">[email protected]</a>&gt; =
wrote:</div><br class=3D"Apple-interchange-newline"><div class=3D""><div =
class=3D""><div class=3D"yahoo-style-wrap" style=3D"font-family:lucida =
console, sans-serif;font-size:13px;"><div dir=3D"ltr" =
data-setdir=3D"false" class=3D"">Cross posted from Seaside Discord =
channel...</div><div dir=3D"ltr" data-setdir=3D"false" class=3D""><br =
class=3D""></div><div dir=3D"ltr" data-setdir=3D"false" class=3D""><div =
class=3D""><div class=3D"">I would like to have an 'html ajax script: =
[...]' method that has a callback:value: pattern.&nbsp;</div><div =
class=3D""><br class=3D""></div><div class=3D"">Something =
like...&nbsp;</div><div class=3D"">&nbsp;&nbsp;&nbsp;&nbsp;html ajax =
script: [:script :value | ...] value: (html jQuery this propertyAt: =
'id')&nbsp;</div><div class=3D""><br class=3D""></div><div class=3D"">Then=
 in the script block 'value' would get the id of 'this', which in an =
ajax callback is undefined.&nbsp;</div><div dir=3D"ltr" =
data-setdir=3D"false" class=3D"">This would allow server code to use =
browser information to build the script.&nbsp;</div><div class=3D""><br =
class=3D""></div><div class=3D"">Anyone done this?</div></div><br =
class=3D""></div><div dir=3D"ltr" data-setdir=3D"false" class=3D""><br =
class=3D""></div><div dir=3D"ltr" data-setdir=3D"false" class=3D"">Bob =
Nemec</div><div dir=3D"ltr" data-setdir=3D"false" class=3D""><br =
class=3D""></div></div></div>_____________________________________________=
__<br class=3D"">seaside mailing list<br class=3D""><a =
href=3D"mailto:[email protected]" =
class=3D"">[email protected]</a><br =
class=3D"">http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seas=
ide<br class=3D""></div></blockquote></div><br =
class=3D""></div></body></html>=

--Apple-Mail=_DCC1DE69-9C09-4DCC-904B-3F147FAD260B--

--===============3788237888823431166==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: base64
Content-Disposition: inline

X19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX19fX18Kc2Vhc2lkZSBt
YWlsaW5nIGxpc3QKc2Vhc2lkZUBsaXN0cy5zcXVlYWtmb3VuZGF0aW9uLm9yZwpodHRwOi8vbGlz
dHMuc3F1ZWFrZm91bmRhdGlvbi5vcmcvY2dpLWJpbi9tYWlsbWFuL2xpc3RpbmZvL3NlYXNpZGUK

--===============3788237888823431166==--