Unfortunately, for me, returning false produced this nasty-looking stack trace:

[ERROR] org.apache.tapestry.internal.services.DefaultRequestExceptionHandler Processing of request failed with uncaught exception: Page Start did not generate any markup when rendered. This could be because its template file could not be located, or because a render phase method in the page prevented rendering. java.lang.RuntimeException: Page Start did not generate any markup when rendered. This could be because its template file could not be located, or because a render phase method in the page prevented rendering. at org .apache .tapestry .internal .services .PageMarkupRendererImpl.renderPageMarkup(PageMarkupRendererImpl.java:58) at $ PageMarkupRenderer_11806dbfeb2 .renderPageMarkup($PageMarkupRenderer_11806dbfeb2.java) at org .apache .tapestry .internal .services .PageResponseRendererImpl .renderPageResponse(PageResponseRendererImpl.java:56)
.
.
.

I don't understand, but I think I'll just return void from the method instead.

Travis


On Feb 10, 2008, at 9:54 PM, Dapeng wrote:

besides the similarity

i guess ur beginRender should return false for redirect

refering to the state diagram

http://tapestry.apache.org/tapestry5/tapestry-core/guide/ rendering.html


Travis McLeskey wrote:
Ah, thanks, that works for me. Here's what I did:

   @Inject
   private Response response;

   @Inject
   private LinkFactory linkFactory;

   public Object beginRender() throws IOException {
       if( isLoginNeeded() )
response.sendRedirect( linkFactory.createPageLink("Login", true) );
       return true;
   }

I wish there were a cleaner way, but that'll do.

Thanks,
Travis



On Feb 10, 2008, at 9:06 PM, Dapeng wrote:

what i am doing is

@Inject
private Response response;

boolean beginRender(){

 if( isRedirectNeeded() ) {
          try { response.sendRedirect("") } catch (Exception e) {}
          return false;
 }

}



Travis McLeskey wrote:
In a page, you can listen for the "activate" event and, for example, if the user doesn't have permission to view that page, you can return a value (Page, Class, String, etc.) that triggers a redirect to another page.

Is it possible to do the same when a component is loading/ rendering? Components don't receive the "activate" event, and I haven't had any luck returning a page object from setupRender() and beginRender().

Thanks,
Travis


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to