Hi,

I have a question when copying an object from a page onto another page 
according to (abbreviated) method below.

        BaseObject sourceResultaatObject = getObject(sourceResultaattype, 
RESULTAATTYPECLASSREFERENCE);
// gets a BaseObject from a page based on the two DocumentReferences for the 
source and the class (custom method)
        BaseObject destinationResultaatObject = 
sourceResultaatObject.duplicate();
        List<String> sourceResultaattypeLeidtTotBesluittype = 
sourceResultaatObject.getListValue(LEIDTTOTBESLUITTYPE)
// contents = [“BST_ER5MLpodilPv6”,"BST_622yQb1ktyvV6"];
        ..
        destinationResultaatObject.setDBStringListValue(LEIDTTOTBESLUITTYPE, 
sourceResultaattypeLeidtTotBesluittype);
        ..
        XWikiDocument XWikiDoc = createPage(destinationResultaattype);
// destinationResultaattype is a newly created DocumentReference
        XWikiDoc.addXObject(destinationResultaatObject);
        savePage(XWikiDoc);
// a custom method to save the XWikiPage.
        sourceResultaatObject = getObject(sourceResultaattype, 
RESULTAATTYPECLASSREFERENCE);
        logger.trace(sourceResultaatObject.toXMLString());

End result I expect to be:

SourceObject: property LEIDTTOTBESLUITTYPE = 
[“BST_ER5MLpodilPv6”,"BST_622yQb1ktyvV6"];
DestinationObject: property LEIDTTOTBESLUITTYPE = 
[“BST_ER5MLpodilPv6”,"BST_622yQb1ktyvV6"];

When I display the old Object immediately after the savePage (toXMLString), the 
result is, that the DBList field is also showing both items. However: When I 
display the page showing the object (using a sheet), the data is gone and the 
DBList is empty. And it looks like it takes a few seconds for this to show up 
this way.

The only solution I have come up with is to fill the List<String> using a for 
loop. In that case, it is working fine.

Maybe I’m missing an essential Java item here but it looks like, when I am 
assigning the DBList values to the List<String> variable, it does not copy the 
data but creates an object link. When assigning it to the new object DBList  
the old link is removed. What I do not understand is, that it takes some time 
before Wiki (or is it?) realizes that it has to remove the DBList values from 
the sourceObject.

Can anyone explain what is happening here? It would be much appreciated.

Peter
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users

Reply via email to