Yes, Click use the same data structure, it does not copy to a new structure. When I used a completely fresh paramMap object for each individual link the error did not happen. Thanks Martin. From: [email protected] Date: Wed, 12 Mar 2014 11:20:54 +0200 Subject: Re: Possible bug with PageLink class? To: [email protected]
Hi, On Wed, Mar 12, 2014 at 11:16 AM, Tamas Balazs <[email protected]> wrote: I have come across with a rather erratic behavior of PageLink class setParameters(Map) method - possible bug, or I do something wrong. Anyway, having created an ArrayList of PageLink I started to populate the list with a for-loop. Upon creating a PageLink objects I set their parameters with the setParameters(Map) method (argument is a TreeMap<String, String>). This is all fine, but if I want to add another parameter for the very same PageLink object (in my case it is the for-counter int) then it always puts the last counter int value! Example: for (int i=0; i<6; i++){list.add(new PageLink("somenames", MyClass.home);list.get(i).setParameters(paramMap); It seems you are sharing a data structure.If Click uses the same data structure then the bug is clear.If Click copies the entries to a new structure then it is something else. list.get(i).setParameter("counter", string.valueOf(i)); } You would expect the link "counter" parameter to be 0, 1, 2, 3, 4,and for the fifth link is 5. In my case it is all 5. The other parameters being passed to the new links from the TreeMap<String, String> are all fine. If I don't add the parameter Map to the new PageLink objects then the "counter" parameters are fine, they are coming up ok, the first link with 0 and so on. Funnily enough if the new PageLinks are initialized as: list.add(new PageLink(string.valueOf(i), MyClass.home); ...then the link name will be the counter int, but if I add the paramMap and then the "counter" parameter, then the counter parameter stays 5 at each link - despite their anchor will be 0, 1, 2 etc... Last but not least, if I add the "counter" parameter to the paramMap within the loop before adding it to the new PageLink objects the "counter" value will be all 5! Well this is it... Tamas
