[xwiki-users] $xwiki.getDocument don't work with dot ?
Hello, I try to obtain DocumentReference from space name and page name with getDocument(String space, String fullname) Parameters: space - Space to use in case no space is defined in the provided fullname fullname - the full name or relative name of the document to load but is doesn't work with dot in document name... My example: document $xwiki.getDocument("MySpace",'My.Dot').getDocumentReference() return xwiki:My.Dot rather than xwiki:MySpace.My\.Dot and document $xwiki.getDocument("MySpace",'MySpace.My.Dot').getDocumentReference() return xwiki:MySpace\.My.Dot :-/ Any idea how I can obtain DocumentReference? (use a regexp seem to be heavy way :-) ) Thxs
Hello, If you're in a component and your objective is to get a DocumentReference, you could use the DocumentReferenceResolver instead: import org.xwiki.model.reference.DocumentReferenceResolver; // ... @Inject private DocumentReferenceResolver<String> docResolver; For the dots issue, I didn't test but I think you can escape those that should not count, like: $xwiki.getDocument("MySpace.My\.Dot") By default it would consider the last '.' dot as the space/page separator. BR, Jeremie 2014-08-19 15:06 GMT+02:00 Pascal BASTIEN <pbasnews-xwiki@yahoo.fr>:
Hello,
I try to obtain DocumentReference from space name and page name with getDocument(String space, String fullname) Parameters: space - Space to use in case no space is defined in the provided fullname fullname - the full name or relative name of the document to load
but is doesn't work with dot in document name...
My example: document $xwiki.getDocument("MySpace",'My.Dot').getDocumentReference() return xwiki:My.Dot rather than xwiki:MySpace.My\.Dot and document $xwiki.getDocument("MySpace",'MySpace.My.Dot').getDocumentReference() return xwiki:MySpace\.My.Dot :-/
Any idea how I can obtain DocumentReference? (use a regexp seem to be heavy way :-) )
Thxs _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
Thxs I forgot to precise it was in velocity code :-/ sorry But I found it: #set ($MyDocumentReference = $services.model.createDocumentReference($doc.wiki, 'MySpace', 'My.Dot')) I can fix my tiny patch now http://jira.xwiki.org/browse/XWIKI-10814 :-) (but Ithink getDocumentReference must be improve) 'more simple to say than to do' :-) Source: http://maven.xwiki.org/site/docs/xwiki-javadoc-5.0.x/org/xwiki/model/interna... public DocumentReference createDocumentReference(String wiki, String space, String page) Create a Document Reference from a passed wiki, space and page names, which can be empty strings or null in which case they are resolved using the resolver. Parameters: wiki - the wiki reference name to use (can be empty or null) space - the space reference name to use (can be empty or null) page - the page reference name to use (can be empty or null) ________________________________ De : Jeremie BOUSQUET <jeremie.bousquet@gmail.com> À : Pascal BASTIEN <pbasnews-xwiki@yahoo.fr>; XWiki Users <users@xwiki.org> Envoyé le : Mardi 19 août 2014 15h52 Objet : Re: [xwiki-users] $xwiki.getDocument don't work with dot ? Hello, If you're in a component and your objective is to get a DocumentReference, you could use the DocumentReferenceResolver instead: import org.xwiki.model.reference.DocumentReferenceResolver; // ... @Inject private DocumentReferenceResolver<String> docResolver; For the dots issue, I didn't test but I think you can escape those that should not count, like: $xwiki.getDocument("MySpace.My\.Dot") By default it would consider the last '.' dot as the space/page separator. BR, Jeremie 2014-08-19 15:06 GMT+02:00 Pascal BASTIEN <pbasnews-xwiki@yahoo.fr>: Hello,
I try to obtain DocumentReference from space name and page name with getDocument(String space, String fullname) Parameters: space - Space to use in case no space is defined in the provided fullname fullname - the full name or relative name of the document to load
but is doesn't work with dot in document name...
My example: document $xwiki.getDocument("MySpace",'My.Dot').getDocumentReference() return xwiki:My.Dot rather than xwiki:MySpace.My\.Dot and document $xwiki.getDocument("MySpace",'MySpace.My.Dot').getDocumentReference() return xwiki:MySpace\.My.Dot :-/
Any idea how I can obtain DocumentReference? (use a regexp seem to be heavy way :-) )
Thxs _______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
On 19 Aug 2014 at 16:09:53, Pascal BASTIEN (pbasnews-xwiki@yahoo.fr(mailto:pbasnews-xwiki@yahoo.fr)) wrote:
Thxs I forgot to precise it was in velocity code :-/ sorry But I found it: #set ($MyDocumentReference = $services.model.createDocumentReference($doc.wiki, 'MySpace', 'My.Dot’))
If all you need is the reference to $doc, then $doc.getDocumentReference() is enough :) Otherwise why do you use $doc.wiki? To get the current wiki? If so it’s not correct and you shoudl use: $services.model.createDocumentReference('', 'MySpace', 'My.Dot’)) See http://extensions.xwiki.org/xwiki/bin/view/Extension/Model+Module#HScriptSer... Thanks -Vincent
I can fix my tiny patch now http://jira.xwiki.org/browse/XWIKI-10814 :-)
(but Ithink getDocumentReference must be improve) 'more simple to say than to do' :-)
Source: http://maven.xwiki.org/site/docs/xwiki-javadoc-5.0.x/org/xwiki/model/interna...
public DocumentReference createDocumentReference(String wiki, String space, String page)
Create a Document Reference from a passed wiki, space and page names, which can be empty strings or null in which case they are resolved using the resolver.
Parameters: wiki - the wiki reference name to use (can be empty or null) space - the space reference name to use (can be empty or null) page - the page reference name to use (can be empty or null)
________________________________ De : Jeremie BOUSQUET À : Pascal BASTIEN ; XWiki Users Envoyé le : Mardi 19 août 2014 15h52 Objet : Re: [xwiki-users] $xwiki.getDocument don't work with dot ?
Hello,
If you're in a component and your objective is to get a DocumentReference, you could use the DocumentReferenceResolver instead:
import org.xwiki.model.reference.DocumentReferenceResolver;
// ...
@Inject private DocumentReferenceResolver docResolver;
For the dots issue, I didn't test but I think you can escape those that should not count, like:
$xwiki.getDocument("MySpace.My\.Dot")
By default it would consider the last '.' dot as the space/page separator.
BR, Jeremie
2014-08-19 15:06 GMT+02:00 Pascal BASTIEN :
Hello,
I try to obtain DocumentReference from space name and page name with getDocument(String space, String fullname) Parameters: space - Space to use in case no space is defined in the provided fullname fullname - the full name or relative name of the document to load
but is doesn't work with dot in document name...
My example: document $xwiki.getDocument("MySpace",'My.Dot').getDocumentReference() return xwiki:My.Dot rather than xwiki:MySpace.My\.Dot and document $xwiki.getDocument("MySpace",'MySpace.My.Dot').getDocumentReference() return xwiki:MySpace\.My.Dot :-/
Any idea how I can obtain DocumentReference? (use a regexp seem to be heavy way :-) )
Thxs
I couldn't use $doc.getDocumentReference() because I tried to obtain documentReference of another document (not current page) I used $doc.wiki because this "another document" was mandatory on the same wiki of current page Thxs I fix my fix (remove $doc.wiki is cleaner and logic) :-) ________________________________ De : "vincent@massol.net" <vincent@massol.net> À : XWiki Users <users@xwiki.org> Envoyé le : Mardi 19 août 2014 18h31 Objet : Re: [xwiki-users] $xwiki.getDocument don't work with dot ? On 19 Aug 2014 at 16:09:53, Pascal BASTIEN (pbasnews-xwiki@yahoo.fr(mailto:pbasnews-xwiki@yahoo.fr)) wrote:
Thxs I forgot to precise it was in velocity code :-/ sorry But I found it: #set ($MyDocumentReference = $services.model.createDocumentReference($doc.wiki, 'MySpace', 'My.Dot’))
If all you need is the reference to $doc, then $doc.getDocumentReference() is enough :) Otherwise why do you use $doc.wiki? To get the current wiki? If so it’s not correct and you shoudl use: $services.model.createDocumentReference('', 'MySpace', 'My.Dot’)) See http://extensions.xwiki.org/xwiki/bin/view/Extension/Model+Module#HScriptSer... Thanks -Vincent
I can fix my tiny patch now http://jira.xwiki.org/browse/XWIKI-10814 :-) (but Ithink getDocumentReference must be improve) 'more simple to say than to do' :-) Source: http://maven.xwiki.org/site/docs/xwiki-javadoc-5.0.x/org/xwiki/model/interna... public DocumentReference createDocumentReference(String wiki, String space, String page) Create a Document Reference from a passed wiki, space and page names, which can be empty strings or null in which case they are resolved using the resolver. Parameters: wiki - the wiki reference name to use (can be empty or null) space - the space reference name to use (can be empty or null) page - the page reference name to use (can be empty or null) ________________________________ De : Jeremie BOUSQUET À : Pascal BASTIEN ; XWiki Users Envoyé le : Mardi 19 août 2014 15h52 Objet : Re: [xwiki-users] $xwiki.getDocument don't work with dot ? Hello, If you're in a component and your objective is to get a DocumentReference, you could use the DocumentReferenceResolver instead: import org.xwiki.model.reference.DocumentReferenceResolver; // ... @Inject private DocumentReferenceResolver docResolver;
For the dots issue, I didn't test but I think you can escape those that should not count, like: $xwiki.getDocument("MySpace.My\.Dot") By default it would consider the last '.' dot as the space/page separator. BR, Jeremie 2014-08-19 15:06 GMT+02:00 Pascal BASTIEN : Hello,
I try to obtain DocumentReference from space name and page name with getDocument(String space, String fullname) Parameters: space - Space to use in case no space is defined in the provided fullname fullname - the full name or relative name of the document to load
but is doesn't work with dot in document name...
My example: document $xwiki.getDocument("MySpace",'My.Dot').getDocumentReference() return xwiki:My.Dot rather than xwiki:MySpace.My\.Dot and document $xwiki.getDocument("MySpace",'MySpace.My.Dot').getDocumentReference() return xwiki:MySpace\.My.Dot :-/
Any idea how I can obtain DocumentReference? (use a regexp seem to be heavy way :-) )
Thxs
_______________________________________________ users mailing list users@xwiki.org http://lists.xwiki.org/mailman/listinfo/users
participants (3)
-
Jeremie BOUSQUET -
Pascal BASTIEN -
vincent@massol.net