How to use export tree

Hello!

Could any one show example of code how to use
image

How to call such dialog on page and how to receive list of pages in jar extension…

Or groove script with example

See xwiki-platform/xwiki-platform-core/xwiki-platform-flamingo/xwiki-platform-flamingo-skin/xwiki-platform-flamingo-skin-resources/src/main/resources/flamingo/export_modal.vm at master · xwiki/xwiki-platform · GitHub and xwiki-platform/xwiki-platform-core/xwiki-platform-web/xwiki-platform-web-war/src/main/webapp/resources/uicomponents/exporter/exporter.js at master · xwiki/xwiki-platform · GitHub .

Thanks.

But how to add it in groovy script?

Need to open export modal
Select some in it
Press export
Pass selection from modal

in my example
I want to change services.query.xwql
to export_modal selection

{{groovy}}
import org.xwiki.environment.*
import org.xwiki.model.reference.*

if (request.confirm == '1') {
  services.query.xwql("select distinct doc.fullName from Document doc where doc.space like 'Sandbox' or doc.space like 'Sandbox.%'").execute().each() {
    print "* Converting ${it} to MD..."
    def itemDoc = xwiki.getDocument(it)
    def newContent = itemDoc.getContent()
    def tmpDir = new File(services.component.getInstance(Environment.class).temporaryDirectory, 'md-export')
    def pathSerializer = services.component.getInstance(EntityReferenceSerializer.TYPE_STRING, 'fspath')
    def outputFile = new File(tmpDir, pathSerializer.serialize(itemDoc.documentReference))
    outputFile.parentFile.mkdirs()
    outputFile << newContent
    println "Saved in ${outputFile.toString()}"
  }
}

println "[[Export>>||queryString='confirm=1']]"
{{/groovy}}

There are two parts:

  • the back-end: it provides the export modal / tree HTML and it handles the submit request
  • the front-end: it shows the export modal / tree and it submits the form

You can’t do both with Groovy. You can only do the back-end stuff. In your snippet you could use the DocumentSelectionResolver component xwiki-platform/xwiki-platform-core/xwiki-platform-oldcore/src/main/java/com/xpn/xwiki/internal/export/DocumentSelectionResolver.java at master · xwiki/xwiki-platform · GitHub (but note that it’s internal so it can change) to get the list of selected document from the tree. But you still need some JavaScript code to open / load the modal / tree and to submit the form.

1 Like

This class resolve my problem!
Thanks a lot!