Macro and custom displayer for presenting an XWiki object property value as a livetable

Hi everyone,

For an ongoing project, I need to display some XWiki objects property value as a livetable. An example use case is the following: a Movie class has a database list property “actors” consisting of potentially many Actor objects; on the Movie page, all actors taking part in the current movie should be listed in a livetable, so that they can be filtered by nationality, age, etc.

Should you know any existing snippet, have any recommendation or specific requirements you would think of, please let me know. I’ll post an update about the result as soon as possible. Cc @caubin

Cheers,

A sample Groovy Script that show all objects and property of them for a page :

        {{groovy}}

        def xWikiUser = "XWiki.user_1"; // Adapt to yours Xwiki

        println "This script Groovy will display all the properties of the object of the user '${xWikiUser}'."

        def etape = request.getParameter("step");

        def countLimit = 0;
        if (countLimit != 0) {
        	println "Search limited to ${countLimit} occurs.";
        }

        if (step == "1"){ 

        	def query = "select obj.className, prop.name, prop.value from XWikiDocument doc, BaseObject obj, StringProperty prop where doc.fullName = '" + xWikiUser +"' and doc.fullName = obj.name and prop.id.id = obj.id order by obj.className, prop.name, prop.value";
        	
        	def result = xwiki.search(query, countLimit, 0);
        	
        	println"";
        	println "# properties of the  class '${xWikiUser}' :${result.stream().count()}"; 	  

        	def doc = xwiki.getDocument("xWikiUser");
        	
        	println "";	
        	println "Liste des propriétés des objets du document '${doc}'"; 
        	println "";
        	
        	println "| Classe | Propriété | Valeur"
        	for (item in result){
        		println "|${item.getAt(0)}|${item.getAt(1)}|${item.getAt(2)}"; 
        	}
        }

        if (step != "1"){
        	println ""
        	println """{{html clean='false' wiki='false'}}""";
        	println """<form><div class='buttonwrapper'><input class='button' type='submit' name='preview' value='Continuer' /></div>""";
        	println """<input type='hidden' name='etape' value='1' /></form>""";
        	println """{{/html}}""";
        } else 	{
        	println ""
        	println """{{html clean='false' wiki='false'}}""";
        	println """<form><div class='buttonwrapper'><input class='button' type='submit' name='preview' value='Retour au début' /></div>""";
        	println """<input type='hidden' name='etape' value='0' /></form>""";
        	println """{{/html}}""";
        }
        {{/groovy}}