Hi,
I think I found a way to do what i want but I identify some issue (probably due to my ugly
code)
- my button SaveAndStuff launch this JS
$('#inline').attr('action','/bin/save/FormSMQ/MyCurrentPage');
// I save my CurrentPage
$('#inline').submit();
// I reopen my CurrentPage in view mode with param to launch my velocity script
window.location =
"https://xxxxxxxxxx/bin/view/FormSMQ/MyCurrentPage?docName=LauchNextProcess";
//Open MyCurrentPage with parameters
In FormSMQ/MyCurrentPage I have this velocity script:
#if("$!request.docName"=='LauchNextProcess'')
## I add a value in a field (list) of MyClass object of currenpage
#set($MyListActions=$MonObj.getValue($ListActionsField))
#set($Discard=$MyListActions.add("$!MonPrefX${docName}"))
#set ($discard=$MonObj.set($ListActionsField,$!MyListActions))
## I save my CurrentPage to save my previous new value
#set ($discard=$doc.save("Nouvelle action => $!MonPrefX${docName}",false))
##Finally I redirect to another page
#$response.sendRedirect($xwiki.getURL("FormSMQ.CaFonctionneOuPas",
'edit',
"template=FormSMQ.ACTemplate&parent=FormSMQ.WebHome&title=FormSMQ.CaFonctionneOuPas&TypeFic=FormSMQ.ACClass"))
## Stop processing, since we already sent a redirect.
#stop
My problem is: when I use "$doc.save", all modifications of my page are lost
(except the new value added)!
If I don't use "$doc.save" all page modifications are saved but of course my
new value is not added :-(
It is a "bit" confused but if someone understand...
--------------------------------------------
En date de : Mar 6.10.15, Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr> a écrit :
Objet: [xwiki-users] Fw : Re: Fw : Re: How to add a button with confirmation to save my
page?
À: "Marius Dumitru Florea" <mariusdumitru.florea(a)xwiki.com>
Cc: "XWiki Users" <users(a)xwiki.org>
Date: Mardi 6 octobre 2015, 18h22
I manage to launch save process of my
page but I didn't manage to pass parameter in this process
:-(
On my page in edit mode, I add a button with this JS code:
function SaveCurrentPage(MyForm, MyParam) {
require(['jquery'], function ($) {
$('#inline').attr('action','/bin/save/FormSMQ/SMQ-M2-FAM-Mon+am%C3%A9lioration');
//$('#inline').attr('method','get');
$('#inline').submit();
});
};
this code save current page and go in the view mode BUT I
can NOT pass some parameters to my velocity code and update
myClass object :-(
In the other way when I submit to view mode with
$('#inline').attr('action','/bin/view/FormSMQ/SMQ-M2-FAM-Mon+am%C3%A9lioration');
My current page is NOT saved but I can pass some parameter
with hidden input (I can catch them with $request.aaaa in
velocity code)
--- En date de : Mar 6.10.15, Marius Dumitru Florea
<mariusdumitru.florea(a)xwiki.com>
a écrit :
De: Marius Dumitru Florea
<mariusdumitru.florea(a)xwiki.com>
Objet: Re: [xwiki-users] Fw : Re: How to add a button
with confirmation to save my
page?
À: "XWiki Users" <users(a)xwiki.org>
Date: Mardi 6 octobre 2015, 12h23
On Tue, Oct 6, 2015 at
1:01 PM, Pascal BASTIEN <pbasnews-xwiki(a)yahoo.fr>
wrote:
First thxs both but it is not
what I want
try to do.
I want to keep default button "Save,
save and contine and Cancel" like
usual.
With velocity I added a button to update
my class object on my page and redirect to another one.
My
button working well in view mode but I want to use it
in
edit mode, then I must save my page before my class
object
update and redirection if not all page modifications
will be
lost.
My main
problem if I rewrite my code in JS is that I can not
update
my class object field attached on my page.
(It's a shame it
doesn't exist an $xwiki.LaunchSaveCurrentPage)
Can I launch
"save page" with javascript? My idea: i launch
save my page in JS from edit mode to view mode with
param
(do redirect on another page). With this way I can
keep
my
nice existant velocity code.
Do you
know how if I can launch "save
page" in JS
then?
I see that a
submit in JS go to preview
mode, maybe I must modify
the
action target of #inline before submit?
The submit button name (e.g.
name="action_save") is not included by
default when you submit the form using
JavaScript (because the form
may have
multiple submit buttons, like in your case, and the
JavaScript code wouldn't know what button
to indicate in the submit
form unless you
explicitly indicate it). You need to add the button
name to the submit parameters when you make the
AJAX save request.
Hope
this helps,
Marius
_______________________________________________
users mailing list
users(a)xwiki.org
http://lists.xwiki.org/mailman/listinfo/users