XWiki User Class Object in Javascript Extension

Hi,

Defined an javascript extension and update the code like below,

var names = [xxx, yyy, zzz];

function checkusers(){
	//do something
}

What i need is to map XWiki users list. Something like below

var names = XWiki.Users;

So that i can process with the list of users in client side.

Note: checked this link

@vmassol

any idea regarding above?

Please don’t ping me, I receive all forum notifications already… :slight_smile: When I don’t reply it’s either because I don’t have the time or because I don’t have the answer. The latter is the case here!

If you need better professional support (with quick response time, etc), consider this option: http://www.xwiki.org/xwiki/bin/view/Main/Support#HProfessionalSupport

@vmassol

Sorry, just to have an idea i have done it.

Putting all the user names in the JavaScript code is definitely not the right solution. You can have thousands of uses. AFAIU you need to filter the user list as you type. The right approach is to filter the users on the server side. See https://github.com/ichord/At.js/wiki/How-to-use-remoteFilter . On XWiki side there is a REST resource that you can use http://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/XWikiRESTfulAPI#HClassresources

/wikis/{wikiName}/classes/{className}/properties/{property}/values?fp={typedText}

where property is of type “List of Users” and the value of fp query string parameter is the text typed after @ in CKEditor.

@mflorea

Thanks for your reply, as of my requirement i need to showcase the list of users and i have tried the following link,

http://www.xwiki.org/xwiki/bin/view/Documentation/UserGuide/Features/XWikiRESTfulAPI#HGettingthelistofusers

But unfortunately i ended up in listing the user name(prasanth_rajendran)

image

but my requirement is to showcase the user’s first name(Prasanth Rajendran)

How can i achieve it?

The /rest/wikis/query resource returns page information (like name, title, modification date, etc) by default and the user name is stored in objects so you don’t get it. In any case, that’s not what I suggested to use. Try with:

/xwiki/rest/wikis/xwiki/classes/XWiki.DocumentClass/properties/author/values?media=json&fp=ad

and replace “ad” in fp=ad with the text typed by the user after @. You need XWiki 9.8+ though.

@mflorea

Thank you so very much… I achieved it.