Uploaded image for project: 'Tapestry'
  1. Tapestry
  2. TAPESTRY-1673

Why does submitType="cancel" kill its listener?

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Critical
    • Resolution: Won't Fix
    • 4.1.2
    • 4.1.6
    • Core Components
    • None
    • Tap 4.1.2, Firefox 2.0.0.5 or IE 7 on Win XP SP2, Safari 2.0.4 or Firefox 2.0.0.5 on OS X 10.4.10, served by Tomcat in JBoss 4.2.1.

    Description

      Is there a reason why submitType kills its component's listener? For example, whereas this listener works...

      <input jwcid="@Submit" type="submit" value="Cancel" action="listener:doCancel">

      ... the listener in this one is ignored...

      <input jwcid="@Submit" type="submit" value="Cancel" action="listener:doCancel" submitType="cancel"/>

      ...and the listener has to be specified on the Form instead...

      <form jwcid="@Form" cancel="listener:doCancel">

      Why is this so? What if I want more than one button of type cancel, each one with its own listener, and possibly its own parameters? I think submitType="refresh" behaves this way, too.

      Here's a working example:

      package sandpit;

      import org.apache.tapestry.html.BasePage;

      public abstract class CancelPage extends BasePage {
      public abstract void setMessage1(String value);
      public abstract void setMessage2(String value);

      public void doComponentListener()

      { setMessage1("doComponentListener() invoked."); }

      public void doFormListener()

      { setMessage2("doFormListener() invoked."); }

      }

      <html jwcid="@Shell" title="">
      <body jwcid="@Body">
      <h2>Demonstration of how submitType="cancel" kills the component's listener</h2>

      <form jwcid="@Form">
      <fieldset>
      <legend>This form does NOT specify a cancel listener</legend>

      Whereas this listener works...<br/>
      <input jwcid="@Submit" type="submit" value="Submit" action="listener:doComponentListener"/> GOOD<br/>
      <code><input jwcid="@Submit" type="submit" value="Submit" action="listener:doComponentListener"/></code><br/><br/>

      ... the listener in this one is ignored, which is bad...<br/>
      <input jwcid="@Submit" type="submit" value="Cancel" submitType="cancel" action="listener:doComponentListener"/> BAD<br/>
      <code><input jwcid="@Submit" type="submit" value="Cancel" submitType="cancel" action="listener:doComponentListener"/></code><br/><br/>
      </fieldset>
      </form>

      <form jwcid="@Form" cancel="listener:doFormListener">
      <fieldset>
      <legend>This form specifies cancel="listener:doFormListener"</legend>

      Whereas this listener works...<br/>
      <input jwcid="@Submit" type="submit" value="Submit" action="listener:doComponentListener"/> GOOD<br/>
      <code><input jwcid="@Submit" type="submit" value="Submit" action="listener:doComponentListener"/></code><br/><br/>

      ... the listener in this one is ignored, and the form's listener takes over, which is questionable...<br/>
      <input jwcid="@Submit" type="submit" value="Cancel" submitType="cancel" action="listener:doComponentListener" /> QUESTIONABLE<br/>
      <code><input jwcid="@Submit" type="submit" value="Cancel" submitType="cancel" action="listener:doComponentListener"/></code><br/><br/>

      ...but in this case the form's listener works... <br/>
      <input jwcid="@Submit" type="submit" value="Cancel" submitType="cancel"/> GOOD<br/>
      <code><input jwcid="@Submit" type="submit" value="Cancel" submitType="cancel"/></code><br/><br/>
      </fieldset>
      </form>

      Message1: <span style="color: red;"><span jwcid="@Insert" value="ognl:message1">Message</span></span><br/>
      Message2: <span style="color: blue;"><span jwcid="@Insert" value="ognl:message2">Message</span></span>
      </body>
      </html>

      Attachments

        1. CancelPage screenshot.jpg
          116 kB
          Geoff Callender

        Activity

          People

            andyhot Andreas Andreou
            geoffcallender Geoff Callender
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: