Custom Livetable _action

In a nutshell, what I would like to do is add a custom _action to a Livetable. Instead of the standard ‘edit’, ‘delete’ I would like to add a ‘Select’ that will then provide a custom redirect by adding different page parameters. I have successfully added the _action but it takes me to an undefined page. I have found in the Livetable Results Macros code where the link is added but I am not sure on how to go about creating the new link. We are using XWiki Enterprise 7.4.4.

Any help would be greatly appreciated.

–Steve

I’m not sure I understand the problem. If you do something similar to what is done for edit/copy/delete/rename actions it doesn’t work? See https://github.com/xwiki/xwiki-platform/blob/master/xwiki-platform-core/xwiki-platform-livetable/xwiki-platform-livetable-ui/src/main/resources/XWiki/LiveTableResultsMacros.xml#L300

Ok, here are some code snippets to better explain. Taking code from a default AWM created page, I first set the column properties as such:

#set ($columnsProperties = {
‘doc.title’: {“type”:“text”,“size”:20},
‘doc.author’: {“type”:“text”,“size”:10,“link”:“author”},
‘doc.date’: {“type”:“text”,“size”:10},
‘_actions’: {“sortable”:false,“filterable”:false,“html”:true,“actions”:[“edit”,“delete”, “select”]}
})

I then set what columns are to be displayed and build table:

#set ($columns = [‘doc.title’, ‘_actions’])
#livetable(‘setupsheets’ $columns $columnsProperties $options)

This displays everything correctly with the exception that the link assigned to the action “select” results in an undefined page.

What I am not sure of is what to edit to create the redirect for custom actions.

Based on your response I am thinking that I need to add a line something to the effect of:

#set($discard = $row.put(‘doc_select_url’, $itemDoc.getURL(‘view’, ‘xpage=PARAMETERS_TO_PASS’)))

Is this correct?

–Steve

Yes, and for this you’ll have to use a custom live table results page. Here’s an example of how you can reuse the code of the default results page and just modify its output to meet your need http://extensions.xwiki.org/xwiki/bin/view/Extension/Livetable+Macro#HModifythedefaultJSON .

It appears that I am still not quite there. If I understand the flow correctly, on the page that I would like the livetable to appear, I have set the options adding to it the option ‘resultPage’ : ‘Setup.SetupSheets.SS_JSON’ . This is the page that would be called to replace the default livetable results page which is Xwiki.LivetableResults. Just to make sure I have everything correct, I copied all the code in the default results page Xwiki.LivetableResults and pasted it into my new, redirected results page Setup.SetupSheets.SS_JSON. I do not see any results and no error is thrown.

If I change resultPage to ‘url’: $xwiki.getURL(‘Setup.SetupSheets.SS_JSON’), I get error 404 with the link listed as https://xwiki/bin/view/Setup/SetupSheets/SS_JSON&offset=1&limit=15&reqNo=1&sort=doc.title&dir=asc

I’m sure there is something small I am missing but just can’t seem to find it.

Thanks,
–Steve

Try with ‘resultPage’: ‘Setup.SetupSheets.SS_JSON.WebHome’, you probably create SS_JSON as a nested page not a terminal page…

I’m following up on this existing thread to ask the following complementary question: once the custom action has been correctfully added, what’s the way to get it translated? I’m struggling to find the entry point…

ok, found it by looking in greater details to the livetable macro definition in “macros.vm”. The translation key to use is “platform.livetable._actions.[myaction]”.