From: users <[email protected]> on behalf of [email protected] <[email protected]> Sent: 05 February 2016 10:25 To: XWiki Users Subject: Re: [xwiki-users] UIExtension Access document holding the UIExtension object On 5 Feb 2016 at 10:15:56, Gerritjan Koekkoek ([email protected](mailto:[email protected])) wrote:
________________________________________ From: users on behalf of [email protected] Sent: 05 February 2016 09:53 To: XWiki Users Subject: Re: [xwiki-users] UIExtension Access document holding the UIExtension object
On 5 Feb 2016 at 09:44:08, Gerritjan Koekkoek ([email protected](mailto:[email protected])) wrote:
________________________________________ From: users on behalf of [email protected] Sent: 05 February 2016 09:39 To: XWiki Users Subject: Re: [xwiki-users] UIExtension Access document holding the UIExtension object
On 5 Feb 2016 at 09:35:36, Gerritjan Koekkoek ([email protected]) wrote:
Hi, Using: So you could have params like:
name = $doc.documentReference (or $doc.fullName) title = $doc.title creator = $doc.creatorReference hasAdmin = $services.authorization.checkAccess(‘ADMIN’, $doc.authorReference)
Looks like the $doc is retrieving the current doc and not the Document that holds the UIExtension object? Any way to access the holding Document?
$xwiki.getDocument(‘name of uiextension doc’)
Thanks, that is indeed the 'simple' solution. This requires updating the parameter if you move the page/object: use Case is distributing the app to another wiki
You could open a jira issue to request an improvement.
FWIW and FYI the code is here: https://github.com/xwiki/xwiki-platform/blob/4533b98fb45a9010198582a7053bc67...
Thanks a lot. It was very helpful. I think the workaround is not too difficult and I think the value of having access to that document meta-information is limited for the typical use-cases of a UIExtension, So a JIRA issue would maybe be too much My suggested work-around would be to use the ExtensionID; and with that ID perform a XWQL query on object of UIExetensionClass where ExtensionID = :ExtensionID(from the uiExtension) Off course this would require Unique ExtensionID's but that would anyway be a good-practice?
yes
Maybe I have a use case for a Jira issue ? Could you evaluate if you consider it a bug: I have set the rights of a page holding an UIExtension object to DENY VIEW to $guest The UIExtension will still show: #set($dashboardMenuItems = $services.uix.getExtensions('dashboard.mainMenu.items',{'sortByParameter' : 'displayorder'}) )
But then performing the XWQL to access meta information of that page works as expected: it does not return any information But I consider it kind of kinky that the object is showing in the getExtensions? Or not? - Gerritjan -Vincent
Thanks -Vincent
________________________________________ From: users on behalf of [email protected] Sent: 04 February 2016 15:32 To: XWiki Users Subject: Re: [xwiki-users] UIExtension Access document holding the UIExtension object
Hi,
On 3 Feb 2016 at 11:24:22, Gerritjan Koekkoek ([email protected](mailto:[email protected])) wrote:
Hi,
We have pages having ONE UIExtension objects of XWiki.UIExtensionClass.
Using as
$services.uix.getExtensions('dashboard.mainMenu.items',{'sortByParameter' : 'displayorder'})
With a #foreach loop we can access all the parameters. (and other extension properties)
But is it possible to get the page information (Name, Title, Creator, Rights)
The use case is that we want a dynamic menu based on that information?
The following did not give the desired result:
#set($dashboardMenuItems = $services.uix.getExtensions('dashboard.mainMenu.items',{'sortByParameter' : 'displayorder'}) )
#foreach($dashboardMenuItem in $dashboardMenuItems)
#set($dashboardMenuItemDocument = $xwiki.getDocument($dashboardMenuItem))
#end
I guess you already know about http://extensions.xwiki.org/xwiki/bin/view/Extension/UIExtension+Module ?
$services.uix.getExtensions returns a List and UIExtension is:
public interface UIExtension { /** * @return the ID of this extension */ String getId();
/** * @return the ID of the extension point this UI extension is providing an extension for */ String getExtensionPointId();
/** * A map of parameters provided by the extension. When providing a new Extension Point the developer must document * the list of parameters he requires. * * @return a map of parameters provided by the extension */ Map getParameters();
/** * @return the {@link Block} that must be rendered when this extension is displayed */ Block execute(); }
So as you can see there’s no way to return anything else here.
However, when you define your UIX you can pass any number of parameters (which are retrieved through calling getParameters() on UIExtension).
So you could have params like:
name = $doc.documentReference (or $doc.fullName) title = $doc.title creator = $doc.creatorReference hasAdmin = $services.authorization.checkAccess(‘ADMIN’, $doc.authorReference) ...
Hope it helps, -Vincent
Gerritjan Koekkoek Vader van Rai Koekkoek (cdls) en voorzitter vereniging CdLS Visit our website Facebook email
users mailing list [email protected] http://lists.xwiki.org/mailman/listinfo/users