xxforms:download on a single click

Posted by SD on
URL: https://discuss.orbeon.com/xxforms-download-on-a-single-click-tp3297720.html

Hi All,

I have a set of documents which are shown to the user from a UI, the user is provided with a download link (xforms:trigger) to download a particular document from the set of documents. On click of a particular download link I would like to go to the database, grab the document and show the download dialog. How can this be achieved?

The current code looks like this


<xforms:trigger appearance="minimal" id="upload-download-trigger">
<xforms:label>Download</xforms:label>
<xforms:action ev:event="DOMActivate">       
<xforms:setvalue ref="instance('selected-document')" value="context()/document-name"/>
<xforms:send submission="get-document"/>
</xforms:action>
</xforms:trigger>



<xforms:submission xxforms:username="xxxxx" xxforms:password="yyyyy" id="get-document" serialization="none" method="get" action="http://localhost:80/exist/rest/db/XXXXXX/info.xml" replace="instance" instance="document-definition-instance">
<xxforms:show ev:event="xforms-submit-done" dialog="download-dialog"/>
</xforms:submission>



<xxforms:dialog id="download-dialog" appearance="minimal" neighbor="upload-download-trigger">
<xforms:output ref="instance('document-definition-instance')/attachment" appearance="xxforms:download">
        <xforms:label>Download instance</xforms:label>
        <xforms:mediatype ref="@mediatype"/>
        <xforms:filename ref="@filename"/>
</xforms:output>
</xxforms:dialog>

Since xxforms:download works with xforms:output, I'm forced to click twice, first on the Download link created by the trigger to go and get the specific document from the DB and then on the Download instance link created by the xforms:output in the download-dialog.

Can the second action be omitted so that download the document just by a single click.

Thanks
--ssethia