cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Simone Gianni <s.gia...@thebug.it>
Subject Re: CForm fb:repeater and binding on java.util.Set
Date Tue, 11 Jul 2006 09:02:47 GMT
Ciao Giuseppe,
the problem with the Set binding is related on how the repeater binding
works. It currently creates the new object, adds it to the collection,
points to it with an xpath expression (collection[1], for example), and
then valorize it.

Unfortunately this leads to some problems when the collection is a Set:
- XPath can perfectly identify an object in a list (mylist[1]) but is
not so good in pointing to a Set, where there is no index.
- If the bean implements it's own public int hashCode() method, that
camputes the hash code depending on field values, then the hash code
will be a certain value when the object is added to the set, and then
change when the object gets valorized, and this confuses the Set a lot
(this is currently a general problem when using a HashSet or HashMap
with objects that change their hash code, and the repeater binding takes
the worse approach in this case)
- Even worse, if in the repeater you are adding 5 new lines, it will
create the first new object, with an hash code of say 0, add it to the
set, then valorize it, then create a new one, which again has a hash
code of 0, and the set will refuse to add it since it already hashed an
object with hash code 0.

I currently have this issue in my cocoon-todo-list, but unfortunately
haven't managed to find the time to work on it seriously. In the
meanwhile, is safe saying that a binding on a Set is not safe :) and a
List is by far more reliable.

You could file a bug on jira about this problem, and if you have quality
time to spend on it let us know!

Hope this helps,
Simone

P.S. For this questions, usually the users mailing list is a better
place to ask.

Giuseppe Di Pierri wrote:

> Does anybody know why the repeater widget fits very well when binding
> with java.util.List objects (if used with beans ob.), but causes some
> strange effect when binding with java.util.Set objects (effects like
> loosing objects or general mismatch in sync between widget and bean
> content or null values in some fb:identity widget)?
>
> AFAICU the problem (hope I'm wrong) could be near the method doSave in
> the class org/apache/cocoon/forms/binding/RepeaterJXPathBinding.java,
> but I am not sure.
>
> Thanks for your help
>
> pino
>
-- 
Simone Gianni

Mime
View raw message