You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by "Kolesnikov, Alexander GNI" <Al...@CIGNA.com> on 2007/08/08 10:37:41 UTC

[T5] Submit control event handler cannot redirect?

I am playing with a simple T5 application that has two pages: Start and
Another.

The Start page contains the following:

<p> 
	<a href="#" t:type="ActionLink" t:id="actionRedirect">Display
Another page</a>
</p>
<t:form t:id="theForm">
	<input type="submit" value="Submit"/>
	<t:submit t:id="submitRedirect" value="Submit Redirect"/>
</t:form>

And here is the page class contents:

@InjectPage
private Another anotherPage;

@OnEvent(value="submit", component="theForm")
Object onFormRedirect() {
	return anotherPage; 
}
	
@OnEvent(component="actionRedirect")
Object onActionRedirect() {
	return anotherPage; 
}
	
@OnEvent(component="submitRedirect")
Object onSubmitRedirect() {
	return anotherPage; 
}

So basically the Start page provides three ways to navigate to Another
page: by submitting the form (using HTML <input type="submit">), by
clicking on the ActionLink and by by clicking on the Sunmit component.
The latter, however, produces exception with the following message:

Event 'selected' from Start:submitredirect received an event handler
method return value of com.packtpub.foundations.pages.Another@5bd978
from com.packtpub.foundations.pages.Start.onSubmitRedirect() (at
Start.java:56). This type of event does not support return values from
event handler methods.

For me, this looks inconsistent. Okay, Submit control generates
'selected' event, not 'submit', not 'action', but wouldn't it be natural
to be able to navigate to another page as a result of a Submit button
press?

Thanks,

Alexander


------------------------------------------------------------------------------
CONFIDENTIALITY NOTICE: If you have received this email in error, please immediately notify the sender by e-mail at the address shown.  This email transmission may contain confidential information.  This information is intended only for the use of the individual(s) or entity to whom it is intended even if addressed incorrectly.  Please delete it from your files if you are not the intended recipient.  Thank you for your compliance.  Copyright 2007 CIGNA
==============================================================================

Re: [T5] Submit control event handler cannot redirect?

Posted by Nick Westgate <ni...@key-planning.co.jp>.
Think of it this way: the answer is "no" if you supply t:defer="false",
because then the redirect would occur before the form completed rewinding.

That would be kind of like an exception. ;-)
http://wiki.apache.org/tapestry/Tapestry5RedirectException

I agree with you that's it's inconsistent though, and could be changed.
The event framework is definitely alpha, IHMO, with all the cool features
already implemented but some deeper issues yet to be resolved.

(In fact I'm about to post a JIRA improvement issue related to events.)

Cheers,
Nick.


Kolesnikov, Alexander GNI wrote:
> For me, this looks inconsistent. Okay, Submit control generates
> 'selected' event, not 'submit', not 'action', but wouldn't it be natural
> to be able to navigate to another page as a result of a Submit button
> press?
> 
> Thanks,
> 
> Alexander
> 
> 
> ------------------------------------------------------------------------------
> CONFIDENTIALITY NOTICE: If you have received this email in error, please immediately notify the sender by e-mail at the address shown.  This email transmission may contain confidential information.  This information is intended only for the use of the individual(s) or entity to whom it is intended even if addressed incorrectly.  Please delete it from your files if you are not the intended recipient.  Thank you for your compliance.  Copyright 2007 CIGNA
> ==============================================================================
> 

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


Re: [T5] Submit control event handler cannot redirect?

Posted by Denny <de...@gmail.com>.
The error message is clear. This type of event does not support return
values from
event handler methods.

Please take a look at http://wiki.apache.org/tapestry/Tapestry5HowToUseForms

Dealing with multiple submits Capter.


On 8/8/07, Kolesnikov, Alexander GNI <Al...@cigna.com> wrote:
>
> I am playing with a simple T5 application that has two pages: Start and
> Another.
>
> The Start page contains the following:
>
> <p>
>         <a href="#" t:type="ActionLink" t:id="actionRedirect">Display
> Another page</a>
> </p>
> <t:form t:id="theForm">
>         <input type="submit" value="Submit"/>
>         <t:submit t:id="submitRedirect" value="Submit Redirect"/>
> </t:form>
>
> And here is the page class contents:
>
> @InjectPage
> private Another anotherPage;
>
> @OnEvent(value="submit", component="theForm")
> Object onFormRedirect() {
>         return anotherPage;
> }
>
> @OnEvent(component="actionRedirect")
> Object onActionRedirect() {
>         return anotherPage;
> }
>
> @OnEvent(component="submitRedirect")
> Object onSubmitRedirect() {
>         return anotherPage;
> }
>
> So basically the Start page provides three ways to navigate to Another
> page: by submitting the form (using HTML <input type="submit">), by
> clicking on the ActionLink and by by clicking on the Sunmit component.
> The latter, however, produces exception with the following message:
>
> Event 'selected' from Start:submitredirect received an event handler
> method return value of com.packtpub.foundations.pages.Another@5bd978
> from com.packtpub.foundations.pages.Start.onSubmitRedirect() (at
> Start.java:56). This type of event does not support return values from
> event handler methods.
>
> For me, this looks inconsistent. Okay, Submit control generates
> 'selected' event, not 'submit', not 'action', but wouldn't it be natural
> to be able to navigate to another page as a result of a Submit button
> press?
>
> Thanks,
>
> Alexander
>
>
>
> ------------------------------------------------------------------------------
> CONFIDENTIALITY NOTICE: If you have received this email in error, please
> immediately notify the sender by e-mail at the address shown.  This email
> transmission may contain confidential information.  This information is
> intended only for the use of the individual(s) or entity to whom it is
> intended even if addressed incorrectly.  Please delete it from your files if
> you are not the intended recipient.  Thank you for your
> compliance.  Copyright 2007 CIGNA
>
> ==============================================================================
>



-- 
Regards

Denny
Site: http://dengyin2000.javaeye.com