Greg Brown wrote:
>
>> - Component#userData is going to be hard to use.
>>  It is very handy to be able to stash extra info on a component, but
>> when multiple libraries all want to do this, it quickly gets out of hand.
>>     
>
> True. We've talked about eliminating it in the past, but there are valid use 
> cases for it. Also, other toolkits include a similar feature. So there's 
> probably no real harm in including it.
>
>   
You kind of missed the important part of the comment i.e.

When multiple libraries all want to do this, they can conflict e.g. if I
add LibraryA and LibraryB to my pivot application, and both libraries
want to enhance standard Pivot behaviour by stashing stuff in the
Component, they
will overwrite each others UserData.

A better solution would be to use a map of values with methods like
   void putUserData(Class key, Object userdata)
   Object getUserData(Class key)
where key is the Class of the client object.

Reply via email to