Can't get properties values from a document's object from another wiki
----------------------------------------------------------------------

                 Key: XWIKI-2051
                 URL: http://jira.xwiki.org/jira/browse/XWIKI-2051
             Project: XWiki Platform
          Issue Type: Bug
          Components: APIs
    Affects Versions: 1.3 M1, 1.2.1
            Reporter: Thomas Mortagne


To reproduce, create a user "toto" on main wiki and execute the following code 
in a any wiki except main wiki
{code}
#set ($document = $xwiki.getDocument("xwiki:XWiki.toto"))
#set ($object = $document.getObject("XWiki.XWikiUsers"))
$object.firstName
{code}

This will print nothing.

The problem is that Object.get(String) reload the XWikiDocument before trying 
to get object field value. To reload the document it uses 
getCollection().getName(); that contains "XWiki.toto"
 and not "xwiki:XWiki.toto" so the wrong document is loaded and when it try to 
get field value, an empty String is returned because field or object does not 
exist.

{code}
    public java.lang.Object get(String name)
    {
        String docname = getCollection().getName();
        try {
            XWikiDocument doc = 
getXWikiContext().getWiki().getDocument(docname, getXWikiContext());
            return doc.display(name, this.getBaseObject(), getXWikiContext());
        } catch (XWikiException e) {
            return null;
        }
    }
{code}

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://jira.xwiki.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        
_______________________________________________
notifications mailing list
[email protected]
http://lists.xwiki.org/mailman/listinfo/notifications

Reply via email to