[Seaside] Page Refresh back to same html element

Rajeev Lochan lochan94 at gmail.com
Tue Jan 1 20:33:37 UTC 2008

Thanks a lot Randal and Tom,
I could accomplish the task with your help and guidance.
The following are the things I did.

1) Add 'identifier' an instance Variable in MySession (which is my root
session class).

2) Add 2 methods #identifier and #identifier: in MyRootComponent ( Which is
a subclass of WAComponent and my root component)

MyRootComponent>> identifier
^ self session identifier

MyRootComponent>>identifier: anId
self session identifier: anId

3) Override #updateUrl: in MyRootComponent

updateUrl: url
"identifier has the html Id of the anchor/element clicked last"
       super updateUrl: url.
       url fragment: self identifier

4)MyRootComponent # renderContentOn: is simple

MyRootComponent>>renderContentOn: html
"model is an OrderedCollection"
self model do: [:eachItem | self renderEachItem: eachItem on: html]

5) #renderEachItem:on: is tweaked a bit to accomodate html anchor name: . I
suppose this can also work with textInputs and submitButtons or any other
form elements.

MyRootComponent>>renderEachItem: eachItem on: html

"I am going to have some temp variables to assign html nextId. Each Item has
title, quantity"
| id1 id2 id3 |
id1 := id2 := id3 := nil.
html text: anItem title.
html text: anItem quantity.
html anchor name: (id1 := html nextId); callback: [self identifier:
id1.selfincrementQuantity: anItem]; with: '+'.
html anchor name: (id2 := html nextId); callback: [self identifier:
id2.selfdecrementQuantity: anItem]; with: '-'.
html anchor name: (id3 := html nextId); callback: [self identifier:
id3.selfdelete: anItem]; with: 'Delete'.

Thanks a lot again to all the experienced users who make our lives easier.
What a way to start a New Year.

Thanks & Regards,

On Jan 1, 2008 10:51 PM, Randal L. Schwartz <merlyn at stonehenge.com> wrote:

> >>>>> "Rajeev" == Rajeev Lochan <lochan94 at gmail.com> writes:
> Rajeev> I tried this and it works out of the box only with a particular
> predefined
> Rajeev> Anchor. As I mentioned above, mine is going to be Dynamically
> built list
> Rajeev> with a lot of items. Is there anyway to assign unique name to all
> anchors.
> Rajeev> One of the solutions I can think of is
> Rajeev> html anchor name: html nextId asString.
> Rajeev> Then somehow pass this information to #updateUrl:
> Just designing out loud, but I suspect your callback could update a state
> variable (in the component) that defines the anchor tag to which to
> scroll,
> and the #updateUrl: of that component would add that tag to the url.
>  Might
> just work, since the callback pass is processed *before* the rendering
> pass.
> --
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
> 0095
> <merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
> Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
> See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl
> training!

Rajeev Lochan

Co-founder, AR-CAD.com

+91 9243468076 (Bangalore)
080 65355873
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20080102/73700dfe/attachment.htm

More information about the seaside mailing list