Dear Wiki user, You have subscribed to a wiki page or wiki category on "Tapestry Wiki" for change notification.
The following page has been changed by NickWestgate: http://wiki.apache.org/tapestry/EasyBrowserRedirection ------------------------------------------------------------------------------ 1. Thow a RedirectException The following extended RedirectException makes this very easy. Thanks to Paul Ferraro for posting this gem to the mailing list. - === Example === + === Example (Tapestry3) === {{{ import org.apache.tapestry.IDirect; @@ -80, +80 @@ } }}} + === Example (Tapestry4) === + {{{ + import java.util.HashMap; + import java.util.Map; + import org.apache.hivemind.impl.RegistryBuilder; + import org.apache.tapestry.IRequestCycle; + import org.apache.tapestry.RedirectException; + import org.apache.tapestry.engine.IEngineService; + import org.apache.tapestry.engine.ILink; + import org.apache.tapestry.services.ServiceConstants; + + public class TapestryRedirectException extends RedirectException { + + public static IEngineService getPageService() { + return (IEngineService)RegistryBuilder.constructDefaultRegistry() + .getService("tapestry.services.Page",IEngineService.class); + } + + public static Map getLinkParams(Strink pageName) { + Map linkParams=new HashMap(); + linkParams.put(ServiceConstants.PAGE,pageName); + return linkParams; + } + + private static final long serialVersionUID = 4049918285694842678L; + + public TapestryRedirectException(String url) + { + super(url); + } + + public TapestryRedirectException(ILink link) + { + this(link.getURL()); + } + + /** + * Use this to redirect the browser to the specified page + */ + public TapestryRedirectException(IRequestCycle cycle, String page) { + this(cycle.getEngine().getInfrastructure().getLinkFactory().constructLink( + TapestryRedirectException.getPageService(),false, + TapestryRedirectException.getLinkParams(page),false)); + } + + } + + }}} + --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
