Built with Seam

You can find the full source code for this website in the Seam package in the directory /examples/wiki. It is licensed under the LGPL.

In some instances you need to do a redirect to a URL outside your application, for example when a given page is widely linked by external sites and is moved to another application, or on SEO situations that require a 301.

package com.boulevardr.ui;


import javax.faces.context.FacesContext;
import javax.servlet.http.HttpServletResponse;

import org.jboss.seam.annotations.In;
import org.jboss.seam.annotations.Name;

@Name("permanentRedirector") public class PermanentRedirector
        @In FacesContext facesContext;
        public void toUrl(String location)
                HttpServletResponse res = (HttpServletResponse)facesContext.getExternalContext().getResponse();
                res.setHeader("Location", location);

on pages.xml:

<page view-id="/page.seam" action="#{permanentRedirector.toUrl('')}" />

It was suggested that this kind of redirect should be done in a Servlet. However, I prefer to keep all flow-related rules on a single location (i. e.: pages.xml), and that was my main motivation behind this solution.