An update on this issue. Please, see below some findings on the issue concerning how
number of results and pagination are show. Thanks!
________________________________________
From: users-bounces(a)xwiki.org [users-bounces(a)xwiki.org] On Behalf Of Rodriguez Fernandez,
Ricardo Julio
Sent: 25 February 2012 02:32
To: users(a)xwiki.org
Subject: Re: [xwiki-users] understanding Livetable Macro (XE 2.4.30451)
>>>>>> Hi! Once again, thank your
very much for your patience. Please, see below...
________________
From: users-bounces(a)xwiki.org [users-bounces(a)xwiki.org] On Behalf Of Marius Dumitru Florea
[mariusdumitru.florea(a)xwiki.com]
Sent: 24 February 2012 09:52
To: XWiki Users
Subject: Re: [xwiki-users] understanding Livetable Macro (XE 2.4.30451)
On Thu, Feb 23, 2012 at 6:58 PM,
<Ricardo.Julio.Rodriguez.Fernandez(a)sergas.es> wrote:
Thanks! Please, see below...
________________________________________
From: users-bounces(a)xwiki.org [users-bounces(a)xwiki.org] On Behalf Of Marius Dumitru
Florea [mariusdumitru.florea(a)xwiki.com]
Sent: 22 February 2012 12:39
To: XWiki Users
Subject: Re: [xwiki-users] understanding Livetable Macro (XE 2.4.30451)
On Wed, Feb 22, 2012 at 1:06 AM,
<Ricardo.Julio.Rodriguez.Fernandez(a)sergas.es> wrote:
Hi! Thanks for your detailed answer. Please, see
below...
--
Ricardo Rodríguez
Research Management and Promotion Technician
Health Research Institute of Santiago de Compostela (IDIS)
http://www.idisantiago.es
________________________________________
From: users-bounces(a)xwiki.org [users-bounces(a)xwiki.org] On Behalf Of Marius Dumitru
Florea [mariusdumitru.florea(a)xwiki.com]
Sent: 20 February 2012 09:03
To: XWiki Users
Subject: Re: [xwiki-users] understanding Livetable Macro (XE 2.4.30451)
Hi Ricardo,
On Sun, Feb 19, 2012 at 12:25 PM,
<Ricardo.Julio.Rodriguez.Fernandez(a)sergas.es> wrote:
Hi all!
First of all, please, allow me to thank again all XWiki Team for this great framework! It
could be it happens that on Sunday I'm prone to purple prose, but I do think I'll
feel the same tomorrow morning! :-)
Now, some doubts here...
I'm not able to understand how filtering does work in Livetable Macro. For instance,
I get a JSON file including a number of results following a modified getgroupmembers.vm.
Here the line of getgroupmembers getting members column
"member" : "$mdoc.getTranslatedDocument().title #if($hasAdmin ||
$isAdvancedUser) (#if($wikiname != 'local')$wikiname:#end$m)#end",
and one of the items in the JSON file...
{
"fullname" : "XWiki.XWikiIDISC04",
"prettyname" : "XWikiIDISC04 (XWiki.XWikiIDISC04)",
"wikiname" : "local",
"memberurl" : "/bin/XWiki/XWikiIDISC04",
"docurl" : "/bin/XWiki/XWikiIDISArealNeurology",
"grayed" : "false",
"doc_viewable" : "true",
"doc_hasadmin" : "${xwiki.hasAccessLevel('admin',
$context.user, $doc)}",
"member" : "Neurobiology (XWiki.XWikiIDISC04)",
"member_url" : "/bin/XWiki/XWikiIDISC04",
"doc_delete_url" :
"/bin/XWiki/XWikiIDISArealNeurology?xpage=deletegroupmember&fullname=XWiki.XWikiIDISC04&ajax=true"
}
The Livetable Macro instance showing group membership reads...
#set($columnOptions = {
"member" : {'link': 'auto', 'type': 'text',
'displayName': 'Research groups'},
But if I use strings content in
$mdoc.getTranslatedDocument().title, I get no results in the filtered database. only
strings in $m (showing the fullname of the document) work fine. You could check this
behaviour on your own here...
http://atrium_km.idisantiago.es/bin/XWiki/XWikiIDISArealNeurology
>
> With Firebug (or any other browser tool that catches XmlHttpRequests)
> you can see that when you filter the live table (e.g. type 'logy') a
> request like this is made:
>
>
http://atrium_km.idisantiago.es/bin/XWiki/XWikiIDISArealNeurology?xpage=get…
>
> Notice 'member=logy' which specifies the filter. Now if you search
> getgroupmembers.vm for '$request.member' (that's how request
> parameters are accessed) you'll see why group members are filtered by
> their document name and not by their document title.
>
Thanks for the explanation. Are these lines the ones concerned in this task?
#set($rm = $xwiki.rightsmanager)
#if($request.member && !$request.member.trim().equals(''))
#set($countm =
$rm.getAllMatchedMembersNamesForGroup($doc.fullName, $request.member, 0, 0,
$order).size())
#set($members = $rm.getAllMatchedMembersNamesForGroup($doc.fullName, $request.member,
$limit, $off, $order))
>>> I replaced these two lines with:
>>>
>>> ----------8<----------
>>> ## Statement to filter group members by their translated title.
>>> #set($statement = "FROM BaseObject as groupObject, StringProperty as
>>> memberField, XWikiDocument as memberDoc WHERE groupObject.name =
>>> :groupName and groupObject.className = 'XWiki.XWikiGroups' and
>>> groupObject.id = memberField.id.id and memberDoc.fullName =
>>> memberField.value and (memberDoc.language = :language or
>>> (memberDoc.language = '' and memberDoc.defaultLanguage = :language))
>>> and lower(memberDoc.title) like :titleFilter")
>>> ## Determine the member count.
>>> #set($countStatement = "SELECT count(memberField.value)
$statement")
>>> #set($query = $services.query.hql($countStatement))
>>> #set($query = $query.bindValue('groupName', $doc.fullName))
>>> #set($query = $query.bindValue('language', $context.language))
>>> #set($query = $query.bindValue('titleFilter',
>>> "%$!request.member.toLowerCase()%"))
>>> #set($countm = $query.execute().get(0))
>>> ## Retrieve a subset of the filtered members.
>>> #set($selectStatement = "SELECT memberField.value $statement ORDER BY
>>> memberDoc.title $order")
>>> #set($query =
$services.query.hql($selectStatement).setLimit($limit).setOffset($off))
>>> #set($query = $query.bindValue('groupName', $doc.fullName))
>>> #set($query = $query.bindValue('language', $context.language))
>>> #set($query = $query.bindValue('titleFilter',
>>> "%$!request.member.toLowerCase()%"))
>>> #set($members = $query.execute())
>>> ---------->8----------
>>>
>>> and it worked for me on a 4.0 snapshot. I'll let you adapt it for your
>>> older version of XWiki Enterprise.
>>>
>>> Hope this helps,
>>> Marius
It helped a lot! It is now working nicely. This instalation has suffered a lot with
exceptions related with Java memory handling. During the trials to get the scrip working,
I've had to restart the server several times. We have being working on this a couple
of years ago to no avail. Right now, it seems to me that it is time for a new upgrade.
I've had to done a couple of minor changes:
1. To remove $order from #set($selectStatement = "SELECT memberField.value
$statement ORDER BY memberDoc.title $order"). This parameter there causes the query
to fail. At lease here running XWiki Enterprise 2.4.30451
2. To sligthly modify $statement. If I only use groupObject.className =
'XWiki.XWikiGroups', the script works to filter groups including other groups. But
not for groups including users or any other kind of document. I modified this condition to
read... (groupObject.className = 'XWiki.XWikiGroups' or groupObject.className =
'XWiki.XWikiUsers').
With this two changes, I'm now sit-back and enjoying these nice Livetables. I'm
sure users will enjoy as well!
Thank you for the example and for following this thread! I keep catching up once again
with XWiki!
Please, let me add two more questions:
1. As I am not using
$rm.getAllMatchedMembersNamesForGroup to filter records, the button changing order of the
list is not longer available. Please, is there any way of getting it working at the same
time I use the customized script to get **$countm** and **$members**?
>>>>
>>>> You removed the ORDER By clause from the select statement. The reason
>>>> it was failing the query is probably because (by the book) you can
>>>> sort only on a field that is selected. HSQLDB didn't complained when
I
>>>> tested but MySql and the rest don't accept this probably. If you
want
>>>> to keep the ORDER BY clause then you have to include memberDoc.title
>>>> in the SELECT clause:
>>>>
>>>> #set($selectStatement = "SELECT memberField.value, memberDoc.title
>>>> $statement ORDER BY memberDoc.title $order")
>>>>
>>>> but then you also have to extract the members list from the query
>>>> result because now each result row is a list with two values.
>>>>>
>>>>> Please, see what is working here...
>>>>>
>>>>> #set($selectStatement = "SELECT memberField.value $statement
ORDER BY memberDoc.title")
>>>>>
>>>>> I think I've not removed at all the ORDER BY clausule and, in
fact, memberDoc.title is accepted even though it is not selected.
>>>>>
>>>>> #set($selectStatement = "SELECT memberField.value $statement
ORDER BY memberDoc.title $order")
>>>>>
>>>>> This is the very same line you initially proposed.
>>>>>
>>>>> I think I got the point. The problem is how $order is set. As
.countAllMembersNamesForGroup is only used for not filtered lists, I've moved these
lines...
>>>>>
>>>>> #set($order = true)
>>>>> #if("$!{request.dir}" == 'desc')
>>>>> #set($order = false)
>>>>>
>>>>> after the #else of the filter statement. It now reads this way...
>>>>>
>>>>> #else
>>>>> #set($order = true)
>>>>> #if("$!{request.dir}" == 'desc')
>>>>> #set($order = false)
>>>>> #end
>>>>> #set($countm = $rm.countAllMembersNamesForGroup($doc.fullName))
>>>>> #set($members =
$rm.getAllMatchedMembersNamesForGroup($doc.fullName, $util.null, $limit, $off, $order))
>>>>> #end
>>>>>
>>>>> When .countAllMembersNamesForGroup is not used, we have to set $order
in a different way. I've tried this within and it worked...
>>>>>
>>>>> #set($order = 'asc')
>>>>> #if("$!{request.dir}" == 'desc')
>>>>> #set($order = 'desc')
>>>>> #end
>>>>>
>>>>> BUT.. I would like to have the same criteria to order both
non-filtered and filtered lists. Thus, using what I've learnt here, I'm sure that
it si not elegant this code, I'm running not these lines:
>>>>>
>>>>> ***
>>>>> #set($order = 'asc')
>>>>> #if("$!{request.dir}" == 'desc')
>>>>> #set($order = 'desc')
>>>>> #end
>>>>> #if($request.member &&
!$request.member.trim().equals(''))
>>>>> ## Statement to filter group members by their translated title.
>>>>> #set($statement = "FROM BaseObject as groupObject,
StringProperty as memberField, XWikiDocument as memberDoc WHERE groupObject.name =
:groupName and (groupObject.className = >>>>>>>
'XWiki.XWikiGroups' or groupObject.className = 'XWiki.XWikiUsers') and
groupObject.id = memberField.id.id and memberDoc.fullName = memberField.value and
(memberDoc.language = :language or >>>>>>> (memberDoc.language =
'' and memberDoc.defaultLanguage = :language)) and lower(memberDoc.title) like
:titleFilter")
>>>>> ## Determine the member count.
>>>>> #set($countStatement = "SELECT count(memberField.value)
$statement")
>>>>> #set($query = $services.query.hql($countStatement))
>>>>> #set($query = $query.bindValue('groupName',
$doc.fullName))
>>>>> #set($query = $query.bindValue('language',
$context.language))
>>>>> #set($query = $query.bindValue('titleFilter',
"%$!request.member.toLowerCase()%"))
>>>>> #set($countm = $query.execute().get(0))
>>>>> ## Retrieve a subset of the filtered members.
>>>>> #set($selectStatement = "SELECT memberField.value $statement
ORDER BY memberDoc.title $order")
>>>>> #set($query =
$services.query.hql($selectStatement).setLimit($limit).setOffset($off))
>>>>> #set($query = $query.bindValue('groupName',
$doc.fullName))
>>>>> #set($query = $query.bindValue('language',
$context.language))
>>>>> #set($query = $query.bindValue('titleFilter',
"%$!request.member.toLowerCase()%"))
>>>>> #set($members = $query.execute())
>>>>> #else
>>>>> #set($statement = "FROM BaseObject as groupObject,
StringProperty as memberField, XWikiDocument as memberDoc WHERE groupObject.name =
:groupName and (groupObject.className =
>>>>> 'XWiki.XWikiGroups' or groupObject.className =
'XWiki.XWikiUsers') and groupObject.id = memberField.id.id and memberDoc.fullName
= memberField.value and (memberDoc.language = :language or
>>>>> (memberDoc.language = '' and memberDoc.defaultLanguage =
:language))")
>>>>> ## Determine the member count.
>>>>> #set($countStatement = "SELECT count(memberField.value)
$statement")
>>>>> #set($query = $services.query.hql($countStatement))
>>>>> #set($query = $query.bindValue('groupName',
$doc.fullName))
>>>>> #set($query = $query.bindValue('language',
$context.language))
>>>>> #set($countm = $query.execute().get(0))
>>>>> ## Retrieve a subset of the filtered members.
>>>>> #set($selectStatement = "SELECT memberField.value $statement
ORDER BY memberDoc.title $order")
>>>>> #set($query =
$services.query.hql($selectStatement).setLimit($limit).setOffset($off))
>>>>> #set($query = $query.bindValue('groupName',
$doc.fullName))
>>>>> #set($query = $query.bindValue('language',
$context.language))
>>>>> #set($members = $query.execute())
>>>>> #end
>>>>> ***
>>>>>
>>>>> This way I can use any file to order the lists. To the best of my
understanding, $xwiki.rightsmanager won'be used anymore in this script. Thus, I'll
commented it out. Am I right? Thanks!
>>>>>
2. The only portion of the simple pages showing group membership I'm not able to
translate is the string introducing the number of results show and the number of them
included in each page. To be clearer...
http://atrium_km.idisantiago.es/bin/download/XWiki/XWikiIDISAreaOncology/at…
In this case, it reads "Resultados 1 -7 de 7 per page of [selector]".
Resultados and de are in Spanish. Per page of, in English. Changing the current language
doesn't affect to this text chunck.
Please, where could I correct this behavior?
>>>>> Looks like
platform.livetable.pagesizeLabel translation key is not
>>>>> translated into Spanish. It is in the most recent versions of XWiki:
>>>>>
>>>>> platform.livetable.pagesizeLabel=por p\u00E1gina de
>>>>>
>>>>> In order to fix this you have to copy
>>>>> ApplicationResources_es.properties from the xwiki-core jar (located
in
>>>>> WEB-INF/lib) to WEB-INF/classes and add the above line. A server
>>>>> restart is needed.
>>>>>
>>>>> Hope this helps,
>>>>> Marius
>>>>>>
>>>>>> Done. I did this before, but I was not able to remember that
solution! Thank you very much. BUT, it doesn't work.
>>>>>> It must be some other problema as far as the translations
doesn't reply to the language settings of each page.For
>>>>>> instance, Results x - y out-of z per page of m, all in English,
appears eventhough I select Spanish or Galician...
>>>>>> This text doesn't change... These keys exist in the concerned
ApplicationResources file:
>>>>>>
>>>>>> # Deprecated:
>>>>>> xe.pagination.results=Results
>>>>>> xe.pagination.results.of=out of
>>>>>>
>>>>>> ui.ajaxTable.outof=out of
>>>>>> ui.ajaxTable.loading=Loading...
>>>>>>
>>>>>> But I'm not able yet of understanding how these, or other
translated strings, are called by this pagination tool. Any help will be welcome! Thanks!
>>>>>>
>>>>>> Ricardo
Please, let me remember that I'm still working with a XWiki Enterprise 2.4.30451
installation! I don't know at what extent these findings could apply to newer
releases. Sorry about the noise, but I do need to keep alive this installation for some
more months! Thus, I'm trying to find workarounds to some issues. Thanks for your
help!
Concerning the issue described above, I found this:
One of the three involved strings is called from macros.vm and it is correctly displayed
following language settings:
/usr/share/tomcat5/webapps/ROOT/templates/macros.vm:
<span>$msg.get('xe.livetable.pagesize.label')</span>
the values contained in the concerned ApplicationResources_language.properties files, per
page of, en p\u00E1xinas de, en p\u00E1ginas de, are correctly rendered each time a table
is loaded in any of the three languages (I'm sure the same will happen for any new set
language!).
The other two strings are called from livetable.js...
/usr/share/tomcat5/webapps/ROOT/resources/js/xwiki/table/livetable.js:var
msg="<strong>"+off+"</strong> -
<strong>"+f+"</strong> $msg.get('xe.pagination.results.of')
<strong>"+this.totalRows+"</strong>";
/usr/share/tomcat5/webapps/ROOT/resources/js/xwiki/table/livetable.js:this.limitsDisplay.innerHTML="$msg.get('xe.pagination.results')
"+msg;
They are marked "Deprecated" in ApplicationResources.properties. And they load
correctly only when the page is loaded for the first time. Once you get the table loaded,
clicks on different languages don't change the string shown. It seems clear to me that
this JavaScript code loads only when the page loads for the first time, thus, any
subsequent hit don't affect the string shown.
Please, how could I force $msg.get('xe.pagination.results.of') and
$msg.get('xe.pagination.results') to show the correct values when I select a
language? Or am I missinterpreting anything and getting a wrong picture of the situation?
Thanks for your help!!!!
Ricardo
Thank you so much for all your help!
Ricardo
#else
#set($countm = $rm.countAllMembersNamesForGroup($doc.fullName))
#set($members = $rm.getAllMatchedMembersNamesForGroup($doc.fullName, $util.null, $limit,
$off, $order))
#end
$doc.fullName clearly appears as a parameter passed to getAllMatchedMembersNameForGroup
method.
> You can find the rights manager source code
here
>
https://github.com/xwiki/xwiki-platform/tree/master/xwiki-platform-core/xwi…
> . Unfortunately it doesn't have a method to retrieve group member
> matched by their document title so you'll have to write this code by
> yourself (either directly in getgroupmembers.vm or in a script service
>
http://platform.xwiki.org/xwiki/bin/view/DevGuide/WritingComponents#HFromwi…
> )
I'm afraid I'm not a developer myself! It is not easy for me to understand that
source code. But, even not been a Java person, is not possible to pass other fields to the
method to get the Livetable filtered? Please, why?
I've also found this...
http://www.xwiki.org/xwiki/bin/view/FAQ/Why+is+it+not+possible+to+filter+on…
I can understand this, but I would like to find/be able to implement a solution here
(XWiki Enterprise 2.4.30451) because:
1. Livetables created showing group members are a really useful tool here. XWiki groups
are rather convenient to organize users and groups and assign them rights on the set of
documents of their concern.
2. Document title is a really, at least until now!, useful piece of information that
allow us, for instance, to store different translations of the name of a group and recover
them using getTranslatedDocument().
3. read-only SQL access to xwikidoc.XWD_TITLE and, for instance, XWD_PARENT offers us a
quite useful source of information to tabulate information on users and groups. It is
simple to create new documents with a given structure in their names to easily filter
contents by type of document.
Livetable filtering is an impressive tool. I would like to enable our users to use
filtering by name in documents like this...
http://atrium_km.idisantiago.es/bin/XWiki/XWikiIDISAreaEndocrinology?langua…
All pages have title: we have edited it in the three available languages.
Must I go through the creation of a new component to get it? Is there any simpler way of
achieving this? Any workaround to be used until I'm able to understand how does work
the whole thing and to write that component?
Thank you for your help,
Ricardo
>
> Hope this helps,
> Marius
Please, why? How could I use $mdoc.getTranslatedDocument().title to filter the list?
Thank you for your help!!!
--
Ricardo Rodríguez
Research Management and Promotion Technician
Health Research Institute of Santiago de Compostela (IDIS)
http://www.idisantiago.es
Nota: A información contida nesta mensaxe e os seus posibles documentos adxuntos é
privada e confidencial e está dirixida únicamente ó seu destinatario/a. Se vostede non é
o/a destinatario/a orixinal desta mensaxe, por favor elimínea. A distribución ou copia
desta mensaxe non está autorizada.
Nota: La información contenida en este mensaje y sus posibles documentos adjuntos es
privada y confidencial y está dirigida únicamente a su destinatario/a. Si usted no es
el/la destinatario/a original de este mensaje, por favor elimínelo. La distribución o
copia de este mensaje no está autorizada.
See more languages:
http://www.sergas.es/aviso_confidencialidad.htm
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
Nota: A información contida nesta mensaxe e os seus posibles documentos adxuntos é
privada e confidencial e está dirixida únicamente ó seu destinatario/a. Se vostede non é
o/a destinatario/a orixinal desta mensaxe, por favor elimínea. A distribución ou copia
desta mensaxe non está autorizada.
Nota: La información contenida en este mensaje y sus posibles documentos adjuntos es
privada y confidencial y está dirigida únicamente a su destinatario/a. Si usted no es
el/la destinatario/a original de este mensaje, por favor elimínelo. La distribución o
copia de este mensaje no está autorizada.
See more languages:
http://www.sergas.es/aviso_confidencialidad.htm
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
Nota: A información contida nesta mensaxe e os seus posibles documentos adxuntos é
privada e confidencial e está dirixida únicamente ó seu destinatario/a. Se vostede non é
o/a destinatario/a orixinal desta mensaxe, por favor elimínea. A distribución ou copia
desta mensaxe non está autorizada.
Nota: La información contenida en este mensaje y sus posibles documentos adjuntos es
privada y confidencial y está dirigida únicamente a su destinatario/a. Si usted no es
el/la destinatario/a original de este mensaje, por favor elimínelo. La distribución o
copia de este mensaje no está autorizada.
See more languages:
http://www.sergas.es/aviso_confidencialidad.htm
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
Nota: A información contida nesta mensaxe e os seus posibles documentos adxuntos é privada
e confidencial e está dirixida únicamente ó seu destinatario/a. Se vostede non é o/a
destinatario/a orixinal desta mensaxe, por favor elimínea. A distribución ou copia desta
mensaxe non está autorizada.
Nota: La información contenida en este mensaje y sus posibles documentos adjuntos es
privada y confidencial y está dirigida únicamente a su destinatario/a. Si usted no es
el/la destinatario/a original de este mensaje, por favor elimínelo. La distribución o
copia de este mensaje no está autorizada.
See more languages:
http://www.sergas.es/aviso_confidencialidad.htm
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
Nota: A información contida nesta mensaxe e os seus posibles documentos adxuntos é privada
e confidencial e está dirixida únicamente ó seu destinatario/a. Se vostede non é o/a
destinatario/a orixinal desta mensaxe, por favor elimínea. A distribución ou copia desta
mensaxe non está autorizada.
Nota: La información contenida en este mensaje y sus posibles documentos adjuntos es
privada y confidencial y está dirigida únicamente a su destinatario/a. Si usted no es
el/la destinatario/a original de este mensaje, por favor elimínelo. La distribución o
copia de este mensaje no está autorizada.
See more languages:
http://www.sergas.es/aviso_confidencialidad.htm