On Thursday, November 6, 2003, at 01:34 PM, Reinhard Poetz wrote:
From: Jeremy Quinn
Hi All,
I am trying to add a 'Cancel' button to a form, so if the user clicks it they exit the current form processing by being redirected to another URL, it is not working as expected.
<snip/>
I guess it is a problem that currently happens following: If you hit the cancel button, the JS cancel function is executed - also the sendPage function is called. But then some CPU cycles later the woody function is called and it calls sendPageAndWait with the current form as content. ... and as you may expect the latter wins ...
I think we have to make sure that always sendPage* the first call is preferred.
OK, I think I have solved it .....
My form flowscript:
. . .
form.showForm (formURI);
if ("cancel".equals (form.getWidget().getSubmitWidget().getId ())) {
cocoon.sendPage("screen/cancel", {message: "You cancelled"});
return;
}
. . .The cancel function:
function cancel (form) {
form.endProcessing (false);
cocoon.log.info ("The user Cancelled");
}The form Model:
<wd:action id="cancel" action-command="cancel">
<wd:label>Cancel</wd:label>
<wd:hint>cancels the current action</wd:hint>
<wd:on-action>
<javascript>
cancel(event.getSourceWidget().getForm());
</javascript>
</wd:on-action>
</wd:action>Phew!! :)
Thanks
regards Jeremy
