You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Javix <s....@gmail.com> on 2012/03/08 16:17:47 UTC
Hwo to redirect to another page from a vois @OnEvent method
Is it possible to redirect to another page from inside a void method
annotated as follows:
@OnEvent(value = EventConstants.ACTIVATE)
public void initPage(Object[] parameters) {
....
if(something goes wrong) {
redirect to home page
}
}
Thank you
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Hwo-to-redirect-to-another-page-from-a-vois-OnEvent-method-tp5547799p5547799.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Hwo to redirect to another page from a vois @OnEvent method
Posted by Dragan Sahpaski <dr...@gmail.com>.
On Thu, Mar 8, 2012 at 4:17 PM, Javix <s....@gmail.com> wrote:
> Is it possible to redirect to another page from inside a void method
> annotated as follows:
>
Yes,
@Inject Response response;
@OnEvent(value = EventConstants.ACTIVATE)
public void initPage(Object[] parameters) throws IOException{
....
if(something goes wrong) {
response.sendRedirect("Some url");
}
Cheers,
Dragan Sahpaski
> @OnEvent(value = EventConstants.ACTIVATE)
> public void initPage(Object[] parameters) {
> ....
> if(something goes wrong) {
> redirect to home page
> }
>
>
> }
>
> Thank you
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Hwo-to-redirect-to-another-page-from-a-vois-OnEvent-method-tp5547799p5547799.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Hwo to redirect to another page from a vois @OnEvent method
Posted by Kalle Korhonen <ka...@gmail.com>.
What Thiago is saying, you can just return the page (class or
instance) if you changed the return type:
@OnEvent(value = EventConstants.ACTIVATE)
public Object initPage(Object[] parameters) throws IOException{
....
if(something goes wrong) {
return MyErrorPage.class;
}
Kalle
On Thu, Mar 8, 2012 at 8:03 AM, Thiago H. de Paula Figueiredo
<th...@gmail.com> wrote:
> On Thu, 08 Mar 2012 12:53:26 -0300, Javix <s....@gmail.com> wrote:
>
>> I don't really know, the method signature was defined as void that's why
>> I'm asking. And as it is void, in java these methods can not return
>> anything.
>
>
> Unless this method is overriding another one, just change its return type
> and do the right thing. ;) Using Response.sendRedirect() isn't very
> Tapestry-ish. :)
>
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer, and
> instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Hwo to redirect to another page from a vois @OnEvent method
Posted by Javix <s....@gmail.com>.
Yeah, it works! I did as you told, - changed the method signature for
Object and return MyClacc.class or null when needed.
thanks a lot !
On 8 March 2012 17:04, Thiago H de Paula Figueiredo [via Tapestry] <
ml-node+s1045711n5547946h80@n5.nabble.com> wrote:
> On Thu, 08 Mar 2012 12:53:26 -0300, Javix <[hidden email]<http://user/SendEmail.jtp?type=node&node=5547946&i=0>>
> wrote:
>
> > I don't really know, the method signature was defined as void that's why
> > I'm asking. And as it is void, in java these methods can not return
> > anything.
>
> Unless this method is overriding another one, just change its return type
>
> and do the right thing. ;) Using Response.sendRedirect() isn't very
> Tapestry-ish. :)
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5547946&i=1>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5547946&i=2>
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/How-to-redirect-to-another-page-from-a-void-OnEvent-method-tp5547799p5547946.html
> To unsubscribe from How to redirect to another page from a void @OnEvent
> method, click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5547799&code=cy5jYW1ib3VyQGdtYWlsLmNvbXw1NTQ3Nzk5fC0xMzg3Nzk1MDI3>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-redirect-to-another-page-from-a-void-OnEvent-method-tp5547799p5548086.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
Re: Hwo to redirect to another page from a vois @OnEvent method
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 08 Mar 2012 12:53:26 -0300, Javix <s....@gmail.com> wrote:
> I don't really know, the method signature was defined as void that's why
> I'm asking. And as it is void, in java these methods can not return
> anything.
Unless this method is overriding another one, just change its return type
and do the right thing. ;) Using Response.sendRedirect() isn't very
Tapestry-ish. :)
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Hwo to redirect to another page from a vois @OnEvent method
Posted by Javix <s....@gmail.com>.
I don't really know, the method signature was defined as void that's why
I'm asking. And as it is void, in java these methods can not return
anything.
On 8 March 2012 16:50, Thiago H de Paula Figueiredo [via Tapestry] <
ml-node+s1045711n5547914h88@n5.nabble.com> wrote:
> On Thu, 08 Mar 2012 12:17:47 -0300, Javix <[hidden email]<http://user/SendEmail.jtp?type=node&node=5547914&i=0>>
> wrote:
>
> > Is it possible to redirect to another page from inside a void method
> > annotated as follows:
>
> Does it really need to be void? If you don't want to redirect, just return
>
> null. It's the same as returning void.
>
> --
> Thiago H. de Paula Figueiredo
> Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
> and instructor
> Owner, Ars Machina Tecnologia da Informação Ltda.
> http://www.arsmachina.com.br
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5547914&i=1>
> For additional commands, e-mail: [hidden email]<http://user/SendEmail.jtp?type=node&node=5547914&i=2>
>
>
>
> ------------------------------
> If you reply to this email, your message will be added to the discussion
> below:
>
> http://tapestry.1045711.n5.nabble.com/How-to-redirect-to-another-page-from-a-void-OnEvent-method-tp5547799p5547914.html
> To unsubscribe from How to redirect to another page from a void @OnEvent
> method, click here<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=unsubscribe_by_code&node=5547799&code=cy5jYW1ib3VyQGdtYWlsLmNvbXw1NTQ3Nzk5fC0xMzg3Nzk1MDI3>
> .
> NAML<http://tapestry.1045711.n5.nabble.com/template/NamlServlet.jtp?macro=macro_viewer&id=instant_html%21nabble%3Aemail.naml&base=nabble.naml.namespaces.BasicNamespace-nabble.view.web.template.NabbleNamespace-nabble.view.web.template.NodeNamespace&breadcrumbs=notify_subscribers%21nabble%3Aemail.naml-instant_emails%21nabble%3Aemail.naml-send_instant_email%21nabble%3Aemail.naml>
>
--
View this message in context: http://tapestry.1045711.n5.nabble.com/How-to-redirect-to-another-page-from-a-void-OnEvent-method-tp5547799p5547922.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
Re: Hwo to redirect to another page from a vois @OnEvent method
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Thu, 08 Mar 2012 12:17:47 -0300, Javix <s....@gmail.com> wrote:
> Is it possible to redirect to another page from inside a void method
> annotated as follows:
Does it really need to be void? If you don't want to redirect, just return
null. It's the same as returning void.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org