How to control ID of a component?

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to control ID of a component?

Sophie424
I would like to control / record the ID of a component for use in the Ajax
behavior of other components.

e.g. I have a ToolbarComponent with links on it. I want those links to have
onClick update behavior, inserting stuff into a different component
ListComponent. To do this the ToolbarComponent needs to use the ID of the
ListComponent. If these were just #renderXYZ methods (instead of separate
component) I could easily pass the ID around. The problem is they are two
separate components, and #renderContentOn: is called by the framework
without the option of passing  in an ID.

I can't do these IDs statically e.g. I may have lots of these on a page.

Any suggestions? Am I thinking of the problem incorrectly?

Thanks!

Sophie




_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
Reply | Threaded
Open this post in threaded view
|

Re: How to control ID of a component?

Lukas Renggli
> I can't do these IDs statically e.g. I may have lots of these on a page.

What about creating an unique ID for each component and store that in
an instance variable?

    '_' , SmallInteger maxVal atRandom asString

makes quite a nice ID. Also WAExternalID from Seaside generates nice
IDs that are very unlikely to collide.

If you don't want to waste any space, you could also use the
#identityHash of the object. In Squeak this is not particularly safe
to do, but in GemStone the OOP gives an ideal and free DOM ID for your
objects.

Cheers,
Lukas

--
Lukas Renggli
http://www.lukas-renggli.ch
_______________________________________________
seaside mailing list
[hidden email]
http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside