[Seaside] Page Refresh back to same html element
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
2) Add 2 methods #identifier and #identifier: in MyRootComponent ( Which is
a subclass of WAComponent and my root component)
^ self session identifier
self session identifier: anId
3) Override #updateUrl: in MyRootComponent
"identifier has the html Id of the anchor/element clicked last"
super updateUrl: url.
url fragment: self identifier
4)MyRootComponent # renderContentOn: is simple
"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
MyRootComponent>>renderEachItem: eachItem on: html
"I am going to have some temp variables to assign html nextId. Each Item has
| 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
> 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
> 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
> and the #updateUrl: of that component would add that tag to the url.
> just work, since the callback pass is processed *before* the rendering
> Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777
> <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
+91 9243468076 (Bangalore)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the seaside