You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Andy Pahne <ap...@sapida.de> on 2012/11/09 20:29:16 UTC

setupRender(): redirecting to different page

I am trying to do a simple thing, which used to work with previous versions,
at least as far as I can remember. Plwase see code snippet below.

The thing is: it never redirects to the "ArticleUnknown" page, even when
article is null. 

I had a look at the docs ("component rendering cheat" sheet and "page
navigation" and "component liefecycle") and though it's not explicitly
mentionened that setupRender() can do this redirects, it is said that
liefecycle methods can do that.

        @InjectPage private ArtikelUnknown artikelUnknown;

	@SetupRender
	Object setupRender() {
		article = articleService.getArticle(articleID);
		if(article == null){
			return artikelUnknown;
		}
		return null;
	}

Am I doing something wrong here? It just seems natural to me to do it like
in the example code.

I remember in previous Tapestry versions there was something like:

    void pageValidate(PageEvent e){

    }

But that does not seem valid anymore, because there is no more a PageEvent
class...





--
View this message in context: http://tapestry.1045711.n5.nabble.com/setupRender-redirecting-to-different-page-tp5717891.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: setupRender(): redirecting to different page

Posted by Andy Pahne <ap...@sapida.de>.
Thank you. I simply remembered it wrong. 

For the curious: this works as expected:

	Object onActivate(long articleID) {
		this.article = articleService.getPublicArticle(articleID);
		if(this.article == null){
			return articleUnknown;
		}
		return null;
	}





--
View this message in context: http://tapestry.1045711.n5.nabble.com/setupRender-redirecting-to-different-page-tp5717891p5717894.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: setupRender(): redirecting to different page

Posted by Thiago H de Paula Figueiredo <th...@gmail.com>.
On Fri, 09 Nov 2012 17:29:16 -0200, Andy Pahne <ap...@sapida.de> wrote:

> I am trying to do a simple thing, which used to work with previous  
> versions, at least as far as I can remember. Plwase see code snippet  
> below.
>
> The thing is: it never redirects to the "ArticleUnknown" page, even when
> article is null.

setupRender() *never* accepted redirections. You should use onActivate()  
for that.

> Am I doing something wrong here? It just seems natural to me to do it  
> like in the example code.

setupRender is a render phase event which exists only in Tapestry 5.  
activate (handled by onActivate() method, if you write one), is not a  
render phase event, so it can be used for redirections. Please check  
http://tapestry.apache.org/page-navigation.html.

> I remember in previous Tapestry versions there was something like:
>
>     void pageValidate(PageEvent e){
>
>     }

Tapestry 5 is a complete rewrite from Tapestry 4, so don't expect that  
anything that worked on T4 to work on T5 unchanged. Things are way easier  
now. :)

-- 
Thiago H. de Paula Figueiredo

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