Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@Specializes
@RequestScoped
public class CidLogicResult extends DefaultLogicResult {
private MutableRequest request;
public CidLogicResult(...., MutableRequest request) {
super(....);
this.request = request;
}
@Override
public <T> T redirectTo(final Class<T> type) {
logger.debug("redirecting to class {}", type.getSimpleName());
return proxifier.proxify(type, new MethodInvocation<T>() {
@Override
public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
checkArgument(acceptsHttpGet(method), "Your logic method must accept HTTP GET method if you want to redirect to it");
try {
String url = router.urlFor(type, method, args);
String path = request.getContextPath() + url;
if (request.getParameter("cid") != null) {
path = path + "?cid=" + request.getParameter("cid");
}
includeParametersInFlash(type, method, args);
logger.debug("redirecting to {}", path);
response.sendRedirect(path);
return null;
} catch (IOException e) {
throw new ProxyInvocationException(e);
}
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.