cancel
Showing results for 
Search instead for 
Did you mean: 

ArrayList<ArrayList<Object>> in datatype any

glaenen
Champ in-the-making
Champ in-the-making
Hello,

I'm trying to fill a datatype "any" property with an object of the type ArrayList<ArrayList<Object>>.
This is working well but I have a strange behaviour when adding an ArrayList<ArrayList<Object>> with only 1 entry on the highest level,
in this case alfresco seems to change the submitted property to ArrayList<Object> and thus putting all the elements of the second level Arraylist into separate elements of the highest level arraylist. (I hope my explanation is a bit clear 🙂 )

This causes problems when adding extra entry's later on because when the initial submit contained only
one entry the property returned by the nodeservice is an ArrayList<Object> and otherwise it an ArrayList<ArrayList<Object>>.
I've a work around by adding a header entry when first setting this property but I would prefer not having to put this header.

Is there an explanation why Alfresco is changing the type of a submitted object?

Thanks,

Glenn
2 REPLIES 2

afaust
Legendary Innovator
Legendary Innovator
Hello,

I'd strongly advise against putting nested lists in properties - or even using the datatype "d:any" at all if not avoidable. Your data structure would probably best be served by using composite nodes, i.e. a main node with a list of children, each maintaining a multi-value, typed property of your actual elements. This way you have cleanly separated 2nd level lists that you can aggregate in your web scripts / code.

What I'd suppose happens here is that the automatic conversion logic of Alfresco when loading properties from the database flattens your collection.

Regards
Axel

mrogers
Star Contributor
Star Contributor
Yes alfresco has slightly different processing for single and multi-valued properties.   And in addition "unspecified" types can be stored by Java Serialization as a last resort.    There may well be something not quite right in the mapping,  but as the post above suggests its a situation best avoided.