[Seaside] Is your code for your
Seaside web-appusing concisemethods?
rickf at ca-flower.com
Tue Jan 30 22:27:04 UTC 2007
Ramon Leon wrote:
> 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".
Thanks.. I knew that but just haven't needed to use them in my
own code until (perhaps) now -- at least in terms of accepting
> So... I'm not sure I like your approach, too much api and block magic to
> avoid a couple of divs. But here goes...
I not sure I'm following your comment about avoiding divs..
If you've got some other suggestions, I'd love to hear them.. (8->
> 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]].
I do see that I was wrapping my blocks in more blocks.. I guess it
was a bad habit since all of my Seaside code that uses "with:" always
has the blocks enclosures.. Thanks for pointing that out!
> 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
In my case, the MSAShoppingCart was not a (Seaside) component (I should
have made that obvious) but more a helper class to hold onto anything
related to a shopping cart such as those items added to the cart, etc.
I was hoping to just be able to tell the cart logic what it needed to
use to write into the offending divs. Obviously I didn't get far with
the whole concept. It sounds like the code below has more or less done
away with the shopping cart altogether..correct?
> renderAddPaperOrderOn: 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.
I suppose I could just keep the shopping cart simple (KISS) and just
have the offending callback/block logic do the necessary updates of
items in the cart with the liveCallbacks as I've already got it.. Is
that my best approach for this sort of problem? If so, I think that's
more or less what I had before I started whacking things around late
Many thanks in advance for your assistance Ramon!
More information about the Seaside