if (argMap.isEmpty()) {
throw new MissingMethodException("redirect",target.getClass(),new Object[]{ argMap });
}
GrailsWebRequest webRequest = (GrailsWebRequest)RequestContextHolder.currentRequestAttributes();
if(target instanceof GroovyObject) {
GroovyObject controller = (GroovyObject)target;
// if there are errors add it to the list of errors
Errors controllerErrors = (Errors)controller.getProperty(ControllerDynamicMethods.ERRORS_PROPERTY);
Errors errors = (Errors)argMap.get(ControllerDynamicMethods.ERRORS_PROPERTY);
if (controllerErrors != null && errors != null) {
controllerErrors.addAllErrors(errors);
}
else {
controller.setProperty(ControllerDynamicMethods.ERRORS_PROPERTY, errors);
}
Object action = argMap.get(GrailsControllerClass.ACTION);
if (action != null) {
argMap.put(GrailsControllerClass.ACTION, establishActionName(action,controller));
}
if (!argMap.containsKey(GrailsControllerClass.NAMESPACE_PROPERTY)) {
// this could be made more efficient if we had a reference to the GrailsControllerClass object, which
// has the namespace property accessible without needing reflection
argMap.put(GrailsControllerClass.NAMESPACE_PROPERTY, GrailsClassUtils.getStaticFieldValue(controller.getClass(), GrailsControllerClass.NAMESPACE_PROPERTY));
}
}
ResponseRedirector redirector = new ResponseRedirector(getLinkGenerator(webRequest));
redirector.setRedirectListeners(redirectListeners);
redirector.setRequestDataValueProcessor(initRequestDataValueProcessor());
redirector.setUseJessionId(useJessionId);
redirector.redirect(webRequest.getRequest(), webRequest.getResponse(), argMap);
return null;
}