Hi Siva,
Have you considered simplifying it to for instance:
<a
href="?action=delete&doc-uri={encode-for-uri($batchDocUri)}&{encode
-for-uri($batchDirUri)}²>Click here to delete</a>
And then inside the current xqy put some logic at the beginning of the
main section that does something like:
let $action := xdmp:get-request-field("action", "view²)
let $action-result :=
if ($action = 'delete') then
(: delete stuff, return a message :)
else ()
return
(: the code you already had, with a placeholder to show $action-result
as feedback to the user.. :)
Cheers,
Geert
PS: The approach of coding your pages in xqy is a little old-fashion. Have
you considered starting with a framework like slush-marklogic-node
instead? Requires a lot more JavaScript skills, but gives a better
separation between front-end and back-end..
On 6/15/16, 12:08 PM, "[email protected] on behalf
of Mani, Sivasubramani (ELS)" <[email protected] on
behalf of [email protected]> wrote:
>Hi Geert,
>
>Now I changed the code like this
>
>return <a href="{$const:BATCH-LIST-URL}" onClick="return
>deleteScheduledBulkBatch('{$batchDocUri}','{$batchDirUri}')">Click here
>to delete</a>
>
>JS
>
>function deleteScheduledBulkBatch(batchDirUri,batchDocUri) {
> try
> {
>
> }
> catch(err)
> {
> alert(err.message);
> }
> return true;
>}
>
>But I don't know how to call the marklogic functions like
>xdmp:document-delete , xdmp:directory-delete,doc-available inside the
>java script. Could you please kindly help me.
>
>
>Thanks & Regards,
>Siva
>
>
>
>-----Original Message-----
>From: [email protected]
>[mailto:[email protected]] On Behalf Of
>[email protected]
>Sent: Wednesday, June 15, 2016 8:54 AM
>To: [email protected]
>Subject: General Digest, Vol 144, Issue 12
>
>Send General mailing list submissions to
> [email protected]
>
>To subscribe or unsubscribe via the World Wide Web, visit
> http://developer.marklogic.com/mailman/listinfo/general
>or, via email, send a message with subject or body 'help' to
> [email protected]
>
>You can reach the person managing the list at
> [email protected]
>
>When replying, please edit your Subject line so it is more specific than
>"Re: Contents of General digest..."
>
>
>Today's Topics:
>
> 1. Re: Regarding XDMP-PREVENTDEADLOCKS (Geert Josten)
>
>
>----------------------------------------------------------------------
>
>Message: 1
>Date: Wed, 15 Jun 2016 07:53:52 +0000
>From: Geert Josten <[email protected]>
>Subject: Re: [MarkLogic Dev General] Regarding XDMP-PREVENTDEADLOCKS
>To: MarkLogic Developer Discussion <[email protected]>
>Message-ID: <d386d52c.dc911%[email protected]>
>Content-Type: text/plain; charset="us-ascii"
>
>Hi Siva,
>
>Is this an xqy module inside MarkLogic? It will probably run the
>xdmp:spawn-function when producing the HTML, rather than on-click. I
>think you better use a href that links to the page itself with a
>request-param indicating some action is required, and handling that
>elsewhere in that code, or make the link point to a different module that
>will execute the task..
>
>Re preventdeadlocks: you can disable the safeguard with the
><prevent-deadlocks> option, see also http://docs.marklogic.com/xdmp:eval..
>
>Cheers,
>Geert
>
>From:
><[email protected]<mailto:general-bounces@developer.
>marklogic.com>> on behalf of "Mani, Sivasubramani (ELS)"
><[email protected]<mailto:[email protected]>>
>Reply-To: MarkLogic Developer Discussion
><[email protected]<mailto:[email protected]>>
>Date: Wednesday, June 15, 2016 at 9:24 AM
>To:
>"[email protected]<mailto:[email protected]>"
><[email protected]<mailto:[email protected]>>
>Subject: [MarkLogic Dev General] Regarding XDMP-PREVENTDEADLOCKS
>
>Hi team,
>
>I got the XDMP-PREVENTDEADLOCKS error while I try to call a marklogic
>function inside the Html hreaf onClick event. Kindly guide me how to
>achieve this.
>
>Code:
>
><dt>Delete</dt>,
> <dd>{
> let $userId := auth:get-current-user-id()
> let $batchId := xs:string(data($batch/@id))
> let $batchDocUri :=
>batlib:get-batch-xml-uri($userId, $batchId)
> let $batchDirUri := concat("/repo/user/",
>$userId,
> $const:PATH-SEP, $batcon:BATCHES,
>$const:PATH-SEP, $batchId, $const:PATH-SEP)
>
> return <a href="{$const:BATCH-LIST-URL}"
>onClick="{
> xdmp:spawn-function(function() {
> let $deletebBatchDir := try {
> xdmp:directory-delete($batchDirUri)
> } catch($e){
> ""
> }
> return (if(doc-available($batchDocUri)) then
> xdmp:document-delete($batchDocUri)
> else(),xdmp:commit())
> },<options xmlns="xdmp:eval">
> <transaction-mode>update</transaction-mode>
></options>)
>
>Error Message:
>
><error:code>XDMP-PREVENTDEADLOCKS</error:code>
> <error:name/>
> <error:xquery-version>1.0-ml</error:xquery-version>
> <error:message>Processing an update from an update with
>different-transaction isolation could deadlock</error:message>
> <error:format-string>XDMP-PREVENTDEADLOCKS:
>xdmp:invoke("/application/views/batch/available-batches.xqy",
>(fn:QName("", "view-data"), map:map(<map:map
>xmlns:xs="http://www.w3.org/2001/XMLSchema"
>xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
>xmlns:map="http://marklogic.com/xdmp/map"><map:entry
>key="batchType"><map:value
>xsi:type="xs:string">norma...</map:map>), fn:QName("",
>"form-data"), ...), <options
>xmlns="xdmp:eval"><isolation>different-transaction</isolation&
>gt;<prevent-deadlocks>t...</options>) -- Processing an update
>from an update with different-transaction isolation could
>deadlock</error:format-string>
> <error:retryable>false</error:retryable>
>
>
>Thanks & Regards,
>Siva
>
>-------------- next part --------------
>An HTML attachment was scrubbed...
>URL:
>http://developer.marklogic.com/pipermail/general/attachments/20160615/0133
>a930/attachment.html
>
>------------------------------
>
>_______________________________________________
>General mailing list
>[email protected]
>Manage your subscription at:
>http://developer.marklogic.com/mailman/listinfo/general
>
>
>End of General Digest, Vol 144, Issue 12
>****************************************
>_______________________________________________
>General mailing list
>[email protected]
>Manage your subscription at:
>http://developer.marklogic.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected]
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general