001 package org.trails.callback;
002
003 import org.apache.commons.logging.Log;
004 import org.apache.commons.logging.LogFactory;
005 import org.apache.tapestry.IRequestCycle;
006 import org.apache.tapestry.RedirectException;
007 import org.apache.tapestry.callback.ICallback;
008 import org.apache.tapestry.engine.IEngineService;
009 import org.trails.engine.TrailsPagesServiceParameter;
010
011 /**
012 * A callback for returning to a given TrailsPage.
013 */
014 public class TrailsPageCallback implements ICallback
015 {
016
017 private static final Log LOG = LogFactory.getLog(TrailsPageCallback.class);
018 private TrailsPagesServiceParameter tpsp;
019 private IEngineService trailsPagesService;
020
021 public TrailsPageCallback(TrailsPagesServiceParameter tpsp, IEngineService trailsPagesService)
022 {
023 this.tpsp = tpsp;
024 this.trailsPagesService = trailsPagesService;
025 }
026
027 public void performCallback(IRequestCycle iRequestCycle)
028 {
029 throw new RedirectException(trailsPagesService.getLink(false, tpsp).getURL());
030 }
031
032 public boolean equals(Object o)
033 {
034 if (this == o) return true;
035 if (o == null || getClass() != o.getClass()) return false;
036
037 TrailsPageCallback that = (TrailsPageCallback) o;
038
039 return tpsp != null ? tpsp.equals(that.tpsp) : that.tpsp == null;
040
041 }
042
043 public int hashCode()
044 {
045 return (tpsp != null ? tpsp.hashCode() : 0);
046 }
047
048 public TrailsPagesServiceParameter getTpsp()
049 {
050 return tpsp;
051 }
052 }