[Seaside] Is your code for your Seaside
web-appusing concisemethods?
Ramon Leon
ramon.leon at allresnet.com
Tue Jan 30 22:03:20 UTC 2007
> Anyway, I'm hoping someone can give me some insight for this
> sort of refactoring..
>
> Thanks --
>
> Signed -- "Stuck in the woods"
Blocks work like this...
block := [Smalltalk beep].
block value. "beep".
block := [:a | Transcript show: a].
block value: "print".
block := [:a :b | Transcript show: a; show: b].
block value: "first arg" value: "second arg".
So... I'm not sure I like your approach, too much api and block magic to
avoid a couple of divs. But here goes...
MSWLI_Admin_Organization>>renderAddPaperOrderOn: html
self shoppingCart
renderCart: [ self renderFamilyAndOrg: (self session org) on: html]
renderScript: [ self renderScrip: self scripListForOrg on: html]
renderDenom: [ self renderDenomFiller: self on: html ]
renderQty: [ self renderQtyBox: self on: html ]
renderSubmit: [ html submitButton liveCallback: [:r | ]; text: 'Add
to Cart' ]
renderCart: [ ... ]
on: html
MSAShoppingCart>>renderCart: headerBlock
renderScript: scripBlock
renderDenom: denomBlock
renderQty: qtyBlock
renderSubmit: submitBlock
renderCart: cartBlock
on: html
html div class: #fieldset_lookalike; with:
[html form:
[headerBlock value.
html div id: #vendorListDropDown; with: scripBlock.
html div id: #denominationListDropDown; with: denomBlock.
html div id: #quantityEntry; with: qtyBlock.
html div id: #addToCart; with: submitDiv.
html div id: 'cart-contents'; with: cartBlock]].
You don't need to wrap blocks inside blocks to pass them to #with:, they're
already blocks, just pass them.
For what you're doing here, at the very least, I'd lose the component and
just make this a custom method on a custom renderer so it'd look like this
instead.
renderAddPaperOrderOn: html
html
renderCart: [ self renderFamilyAndOrg: (self session org) on: html]
renderScript: [ self renderScrip: self scripListForOrg on: html]
renderDenom: [ self renderDenomFiller: self on: html ]
renderQty: [ self renderQtyBox: self on: html ]
renderSubmit: [ html submitButton liveCallback: [:r | ]; text: 'Add
to Cart' ]
renderCart: [ ... ]
Because what you're doing doesn't really call for a component, just a custom
rendering method.
Ramon Leon
http://onsmalltalk.com
More information about the Seaside
mailing list