Perfect. Thank you. On Fri, Jun 3, 2011 at 12:41 PM, Josh Canfield <joshcanfi...@gmail.com> wrote: >> Is there a simple way to do something similar and get a 301 permanent >> redirect? In particular, can I modify the PageRenderLinkWithContext to >> control the type of redirect? > > Tapestry eventually calls ServletResponse.sendRedirect, which is > always a 302. If you want to send a 301 you have to do it manually. > > Here's some code that works in the same way as HttpError. > > public class PermanentRedirect { > private Link link; > > public PermanentRedirect(Link link) { > this.link = link; > } > > public Link getLink() { > return link; > } > } > > // in AppModule > public void contributeComponentEventResultProcessor( > final Response response, > MappedConfiguration<Class, ComponentEventResultProcessor> > configuration > ) { > configuration.add(PermanentRedirect.class, new > ComponentEventResultProcessor<PermanentRedirect>() { > public void processResultValue(PermanentRedirect value) > throws IOException { > response.setHeader("Location", > value.getLink().toAbsoluteURI()); > // Send error commits the response > response.sendError(301, "Moved Permanently"); > } > }); > } > > Josh > > On Fri, Jun 3, 2011 at 9:13 AM, Mark <mark-li...@xeric.net> wrote: >> A have an onActivate method like this: >> >> Object onActivate(EventContext context) { >> >> //we have what we need to render the page >> if(context.getCount() == 2) { >> this.keyword = context.get(String.class,0); >> this.page = context.get(Integer.class, 1); >> quotes = quoteService.getQuotesForKeyword(keyword); >> return null; >> } >> >> //Missing a context, redirect to default context >> if(context.getCount() == 1) { >> this.keyword = context.get(String.class, 0); >> return >> pageRenderLinkSource.createPageRenderLinkWithContext("keyword", >> keyword, 1); >> } >> >> //Not context at all, do a 404. >> return new HttpError(404, "Resource Not Found"); >> } >> >> >> Returning a PageRenderLinkWithContext does a 302 temporary redirect. >> return pageRenderLinkSource.createPageRenderLinkWithContext("keyword", >> keyword, 1); >> >> Is there a simple way to do something similar and get a 301 permanent >> redirect? In particular, can I modify the PageRenderLinkWithContext to >> control the type of redirect? >> >> Mark >> >> --------------------------------------------------------------------- >> To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org >> For additional commands, e-mail: users-h...@tapestry.apache.org >> >> > > --------------------------------------------------------------------- > To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org > For additional commands, e-mail: users-h...@tapestry.apache.org > >
--------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org