use of org.springframework.ui.ModelMap in project jstorm by alibaba.
the class FilesController method show.
@RequestMapping(value = "/files", method = RequestMethod.GET)
public String show(@RequestParam(value = "cluster", required = true) String cluster_name, @RequestParam(value = "host", required = true) String host, @RequestParam(value = "port", required = false) String port, @RequestParam(value = "dir", required = false) String dir, ModelMap model) {
cluster_name = StringEscapeUtils.escapeHtml(cluster_name);
dirs.clear();
files.clear();
Map conf = UIUtils.readUiConfig();
if (StringUtils.isBlank(dir)) {
dir = ".";
}
String[] path = dir.split("/");
model.addAttribute("path", path);
int i_port;
if (StringUtils.isBlank(port)) {
i_port = ConfigExtension.getNimbusDeamonHttpserverPort(conf);
} else {
i_port = JStormUtils.parseInt(port);
}
//proxy request for files info
String summary = requestFiles(host, i_port, dir);
model.addAttribute("summary", summary);
model.addAttribute("files", files);
model.addAttribute("dirs", dirs);
// status save
model.addAttribute("clusterName", cluster_name);
model.addAttribute("host", host);
model.addAttribute("port", i_port);
model.addAttribute("parent", dir);
UIUtils.addTitleAttribute(model, "Files");
return "files";
}
use of org.springframework.ui.ModelMap in project head by mifos.
the class ApprovalRESTController method reject.
@RequestMapping(value = "id-{id}/reject", method = RequestMethod.POST)
public ModelMap reject(@PathVariable(value = "id") Long id) throws Exception {
ModelMap model = new ModelMap();
approvalService.reject(id);
model.addAttribute("status", "success");
return model;
}
use of org.springframework.ui.ModelMap in project head by mifos.
the class ApprovalRESTController method approve.
@RequestMapping(value = "id-{id}/approve", method = RequestMethod.POST)
public ModelMap approve(@PathVariable(value = "id") Long id) throws Exception {
ModelMap model = new ModelMap();
Object result = approvalService.approve(id);
if (result.toString().startsWith("Error")) {
model.addAttribute("status", "error");
} else {
model.addAttribute("status", "success");
}
model.addAttribute("result", result);
return model;
}
use of org.springframework.ui.ModelMap in project spring-framework by spring-projects.
the class RedirectAttributesMethodArgumentResolver method resolveArgument.
@Override
public Object resolveArgument(MethodParameter parameter, ModelAndViewContainer mavContainer, NativeWebRequest webRequest, WebDataBinderFactory binderFactory) throws Exception {
ModelMap redirectAttributes;
if (binderFactory != null) {
DataBinder dataBinder = binderFactory.createBinder(webRequest, null, null);
redirectAttributes = new RedirectAttributesModelMap(dataBinder);
} else {
redirectAttributes = new RedirectAttributesModelMap();
}
mavContainer.setRedirectModel(redirectAttributes);
return redirectAttributes;
}
use of org.springframework.ui.ModelMap in project spring-framework by spring-projects.
the class ExceptionHandlerExceptionResolver method doResolveHandlerMethodException.
/**
* Find an {@code @ExceptionHandler} method and invoke it to handle the raised exception.
*/
@Override
protected ModelAndView doResolveHandlerMethodException(HttpServletRequest request, HttpServletResponse response, HandlerMethod handlerMethod, Exception exception) {
ServletInvocableHandlerMethod exceptionHandlerMethod = getExceptionHandlerMethod(handlerMethod, exception);
if (exceptionHandlerMethod == null) {
return null;
}
exceptionHandlerMethod.setHandlerMethodArgumentResolvers(this.argumentResolvers);
exceptionHandlerMethod.setHandlerMethodReturnValueHandlers(this.returnValueHandlers);
ServletWebRequest webRequest = new ServletWebRequest(request, response);
ModelAndViewContainer mavContainer = new ModelAndViewContainer();
try {
if (logger.isDebugEnabled()) {
logger.debug("Invoking @ExceptionHandler method: " + exceptionHandlerMethod);
}
Throwable cause = exception.getCause();
if (cause != null) {
// Expose cause as provided argument as well
exceptionHandlerMethod.invokeAndHandle(webRequest, mavContainer, exception, cause, handlerMethod);
} else {
// Otherwise, just the given exception as-is
exceptionHandlerMethod.invokeAndHandle(webRequest, mavContainer, exception, handlerMethod);
}
} catch (Throwable invocationEx) {
// probably an accident (e.g. failed assertion or the like).
if (invocationEx != exception && logger.isWarnEnabled()) {
logger.warn("Failed to invoke @ExceptionHandler method: " + exceptionHandlerMethod, invocationEx);
}
// Continue with default processing of the original exception...
return null;
}
if (mavContainer.isRequestHandled()) {
return new ModelAndView();
} else {
ModelMap model = mavContainer.getModel();
HttpStatus status = mavContainer.getStatus();
ModelAndView mav = new ModelAndView(mavContainer.getViewName(), model, status);
mav.setViewName(mavContainer.getViewName());
if (!mavContainer.isViewReference()) {
mav.setView((View) mavContainer.getView());
}
if (model instanceof RedirectAttributes) {
Map<String, ?> flashAttributes = ((RedirectAttributes) model).getFlashAttributes();
request = webRequest.getNativeRequest(HttpServletRequest.class);
RequestContextUtils.getOutputFlashMap(request).putAll(flashAttributes);
}
return mav;
}
}
Aggregations