On 19 Aug 2014 at 16:09:53, Pascal BASTIEN
([email protected](mailto:[email protected])) 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#HScriptServiceAPI
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/internal/scripting/ModelScriptService.html#createDocumentReference%28java.lang.String,%20java.lang.String,%20java.lang.String%29
>
> 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
[email protected]
http://lists.xwiki.org/mailman/listinfo/users