[
http://jira.xwiki.org/jira/browse/XWIKI-2051?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Thomas Mortagne updated XWIKI-2051:
-----------------------------------
Summary: Can't get properties values from a document's api Object from
another wiki (was: Can't get properties values from a document's object from
another wiki)
Description:
Create a class on the main wiki and a document containing an object of this
class and trying to get any value of this object from any wiki except main wiki
using :
{code}
#set ($document = $xwiki.getDocument(xwiki:<Document full name>))
#set ($object = $document.getObject(<ClassName>))
$object.<field_name>
{code}
This will print nothing.
The problem is that BaseObject does not contains any information about the wiki
it was retrieved from even document or class names that are full names and not
prefixed full names. So when it trys to get the class to be able to correctly
display the field value it can't find the class and display nothing.
was:
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.first_name
{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}
> Can't get properties values from a document's api Object from another wiki
> --------------------------------------------------------------------------
>
> Key: XWIKI-2051
> URL: http://jira.xwiki.org/jira/browse/XWIKI-2051
> Project: XWiki Core
> Issue Type: Bug
> Components: APIs
> Affects Versions: 1.2.1, 1.3 M1
> Reporter: Thomas Mortagne
> Fix For: 1.3 M2
>
>
> Create a class on the main wiki and a document containing an object of this
> class and trying to get any value of this object from any wiki except main
> wiki using :
> {code}
> #set ($document = $xwiki.getDocument(xwiki:<Document full name>))
> #set ($object = $document.getObject(<ClassName>))
> $object.<field_name>
> {code}
> This will print nothing.
> The problem is that BaseObject does not contains any information about the
> wiki it was retrieved from even document or class names that are full names
> and not prefixed full names. So when it trys to get the class to be able to
> correctly display the field value it can't find the class and display nothing.
--
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