cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jorg Heymans ...@domek.be>
Subject Re: repeater calls row-path method n+1 times
Date Fri, 24 Sep 2004 15:04:19 GMT
I took the form2bean.flow example that is under CForms Block Samples 
(link is called "Bean Binding") and enhanced Form2Bean.java with a bit 
of get/set logging. I changed the calling flowscript method (form2bean 
in binding_example.js) to add 4 Contacts instead of 1.

Findings:
- getContacts() is called 5 times upon loading
- when removing 3 elements and saving the form, getContacts() is called 
7 times. setContacts() is called once for each removed element.
- at the end getContacts() is called another 3 times.

This is important to know when hooking up CForms to an O/R mapping. I am 
curious to know how other people have gotten around this when dealing 
with large repeaters.


Here is the output in case anyone is interested.

Upon loading the form initially
---------------------------------
addContact() 1
addContact() 2
addContact() 3
addContact() 4
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()



removed contact 4,3,2 using the repeater remove button, pressed submit
-----------------------------------------------------------------------
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
getContacts() returning collection of size 4
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
     id=4 name=Hermann4
end getContacts()
setContacts() with collection of size 3
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
     id=3 name=Hermann3
end setContacts()
setContacts() with collection of size 2
elements are :
     id=1 name=Hermann1
     id=2 name=Hermann2
end setContacts()
setContacts() with collection of size 1
elements are :
     id=1 name=Hermann1
end setContacts()
getContacts() returning collection of size 1
elements are :
     id=1 name=Hermann1
end getContacts()
getContacts() returning collection of size 1
elements are :
     id=1 name=Hermann1
end getContacts()
getContacts() returning collection of size 1
elements are :
     id=1 name=Hermann1
end getContacts()



Jorg Heymans wrote:
> Hi,
> 
> Bringing this over from user@ , this is just too unlogical for me.
> 
> Say formbean has a Collection called "smallbeans" of "smallbean" objects
> and i want to have a repeater for this.
> 
> then the binding looks like
> <fb:repeater id="myrepeater" parent-path="." row-path="smallbeans">
> 
> formbean.java has getSmallbeans() and setSmallbeans().
> 
> When loading this repeater, getSmallbeans() gets called n+1 times, where 
> n is the number of elements in the collection. Now lets say that the 
> repeater is populated from a fairly heave database query that returns 
> around 100 entries - you get the picture :)
> 
> Is this a normal repeater feature? Shouldn't it be enough for the 
> repeater to call the method only once as it returns the whole collection 
> anyway?
> 
> 
> Thoughts?
> Jorg Heymans
> 
> 


Mime
View raw message