You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tapestry.apache.org by "Jesse Kuhnert (JIRA)" <de...@tapestry.apache.org> on 2008/01/29 22:04:34 UTC

[jira] Commented: (TAPESTRY-1673) Why does submitType="cancel" kill its listener?

    [ https://issues.apache.org/jira/browse/TAPESTRY-1673?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12563665#action_12563665 ] 

Jesse Kuhnert commented on TAPESTRY-1673:
-----------------------------------------

I'm not entirely sure what can be done about this issue......If you look at the documentation on the Form success/cancel/refresh combined with the knowledge that it's impossible to know that any particular button has been clicked unless you do rewind the whole form - it makes things "tricky". 

The cancel logic is currently happening because FormSupportImpl reads the submit mode parameter and doesn't even rewind the form.   I'm not sure how we can bypass this functionality without breaking existing applications...I'm not really sure.

The refresh listeners should have their listeners called correctly - if this isn't happening for you please let me know.  

You can of course very easily just use a normal listener and have it perform whatever cancel logic you need still though right?   

At the very least the various submit buttons/links should probably throw a runtime exception indicating that you can't have a submit type of "cancel" and a listener/action bound as it will never be called. 

thoughts?

> Why does submitType="cancel" kill its listener?
> -----------------------------------------------
>
>                 Key: TAPESTRY-1673
>                 URL: https://issues.apache.org/jira/browse/TAPESTRY-1673
>             Project: Tapestry
>          Issue Type: Bug
>          Components: Core Components
>    Affects Versions: 4.1.2
>         Environment: 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.
>            Reporter: Geoff Callender
>            Assignee: Andreas Andreou
>            Priority: Critical
>             Fix For: 4.1.4
>
>         Attachments: CancelPage screenshot.jpg
>
>
> 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>&lt;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>&lt;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>&lt;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>&lt;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>&lt;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>

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tapestry.apache.org
For additional commands, e-mail: dev-help@tapestry.apache.org