I’ve been experimenting with using the org.xwiki.model.reference.DocumentReference document picker in macros, and I’m hitting a problem that may simply be due to my lack of understanding of the possibilities with this.
In short, when I want to pick a document root, I can’t when using the UI. See this example:
There are many pages under the root that I’m trying to pick (in this case, “OIT Knowledge Base”), and these show up instead of the actual page I’m trying to pick.
Is this a by-design limitation? Sorting problem?
FWIW, if I simply enter in the document reference text, it works marvelously, though I’m still unable to select it in the drop-down list. It would be a much better user experience if it were possible to select the page in the UI.
So the intention is to match the page name or its title. The implementation doesn’t properly match the page name though:
String matchTerminalPage = "doc.name <> :defaultDocName and upper(doc.fullName) like :keywords";
String matchNestedPage = "doc.name = :defaultDocName and upper(doc.space) like :keywords";
We’re basically matching:
the page full reference (without the wiki part) for terminal pages
the space full reference (without the wiki part) for nested pages
We should instead match:
the page name (last part of the reference) for terminal pages (easy, just have to replace doc.fullName with doc.name)
the last space name for nested paged (a bit more complex because we need to join the spaces table to be able to get the last space name)
Btw, I often work around issues with the page picker by copying the “Page Reference” from the page’s “Information” tab and paste it in the page picker field directly. This works … most of the time, though of course it is not how the page picker is intended to be used.
@mflorea, is doc.title a good matching point? I’m still coming up to speed on the xwiki data structures, but it seems like that (with some execptions that may be important?) is the piece we’re generally wanting to match on