cocoon-docs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From da...@cocoon.zones.apache.org
Subject [DAISY] Created: How do I implement a cancel button in Cocoon Forms?
Date Sun, 05 Mar 2006 17:39:02 GMT
A new document has been created.

http://cocoon.zones.apache.org/daisy/documentation/860.html

Document ID: 860
Branch: main
Language: default
Name: How do I implement a cancel button in Cocoon Forms?
Document Type: FAQ
Created: 3/5/06 5:38:48 PM
Creator (owner): Bruno Dumon
State: publish

Parts
=====

Content
-------
Mime type: text/xml
Size: 1112 bytes
Content:
<html>
<body>

<p>The key to implementing a cancel button -- or any button you where you want
to exit the current form and move on to somewhere else -- is to add an event
handler to the button which indicates to the form that it should end the form
processing, and then checking the if the submit widget of the form is the cancel
button.</p>

<p>Below follow some snippets which illustrate this.</p>

<p>In the form definition, add the declaration of a cancel button:</p>

<pre>    &lt;fd:action id="cancel"&gt;
      &lt;fd:label&gt;Cancel&lt;/fd:label&gt;
      &lt;fd:on-action&gt;
        &lt;fd:javascript&gt;
          event.getSourceWidget().getForm().endProcessing(false);
        &lt;/fd:javascript&gt;
      &lt;/fd:on-action&gt;
    &lt;/fd:action&gt;
</pre>

<p>In the flowscript, after the <tt>form.showForm</tt> function returns,
you can
check if the user pressed the cancel button using form.submitId:</p>

<pre>    var form = new Form("myform.xml");
    form.showForm("myform-display-pipeline");

    if (form.submitId == "cancel") {
      // the user pressed cancel
    }
</pre>

</body>
</html>

Fields
======
Tags: forms

Collections
===========
The document belongs to the following collections: documentation

Mime
View raw message