- in a subwiki, add a database list property (let's call it p) to a class, in which you add a query that selects both key and value for this database list (e.g. select doc.fullName, doc.title from XWikiDocument doc, BaseObject obj where doc.fullName = obj.name and obj.className='AppToReference.AppToReferenceClass' and doc.fullName != 'AppToReference.AppToReferenceTemplate' where "AppToReference.AppToReferenceClass" exists and has some documents with objects)'
- create a document (let's call it D) with an object of this modified class, choose a value for the db list property
- in view mode, this document will properly display the title of the chosen value
- in another subwiki (or in the main wiki), in a test page, execute
- the value displayed will be the key of the database list (that is, the fullname of the referenced document) instead of the value (the title of the chosen referenced document).
Make sure to not enable cache for the dblist property!
This issue is caused by the fact that, in the displayView function of the dblist class, when the value to be displayed is searched (based on the stored key), the query of the dblist is executed, and it's executed for the current wiki (context.database) which does not correspond to the wiki of the class in which the dblist property. So the dblist query is relative to the database of the class, but it's executed in another wiki.