/** * Whether the underlying model contains the given attribute name. * A shortcut for {@code getModel().containsAttribute(String)}. */ public boolean containsAttribute(String name) { return getModel().containsAttribute(name); }
/** * Whether the underlying model contains the given attribute name. * A shortcut for {@code getModel().containsAttribute(String)}. */ public boolean containsAttribute(String name) { return getModel().containsAttribute(name); }
/** * Add {@link BindingResult} attributes to the model for attributes that require it. */ private void updateBindingResult(NativeWebRequest request, ModelMap model) throws Exception { List<String> keyNames = new ArrayList<>(model.keySet()); for (String name : keyNames) { Object value = model.get(name); if (value != null && isBindingCandidate(name, value)) { String bindingResultKey = BindingResult.MODEL_KEY_PREFIX + name; if (!model.containsAttribute(bindingResultKey)) { WebDataBinder dataBinder = this.dataBinderFactory.createBinder(request, value, name); model.put(bindingResultKey, dataBinder.getBindingResult()); } } } }
/** * Add {@link BindingResult} attributes to the model for attributes that require it. */ private void updateBindingResult(NativeWebRequest request, ModelMap model) throws Exception { List<String> keyNames = new ArrayList<>(model.keySet()); for (String name : keyNames) { Object value = model.get(name); if (value != null && isBindingCandidate(name, value)) { String bindingResultKey = BindingResult.MODEL_KEY_PREFIX + name; if (!model.containsAttribute(bindingResultKey)) { WebDataBinder dataBinder = this.dataBinderFactory.createBinder(request, value, name); model.put(bindingResultKey, dataBinder.getBindingResult()); } } } }
/** * Whether the underlying model contains the given attribute name. * A shortcut for {@code getModel().containsAttribute(String)}. */ public boolean containsAttribute(String name) { return getModel().containsAttribute(name); }
/** * Whether the underlying model contains the given attribute name. * A shortcut for {@code getModel().containsAttribute(String)}. */ public boolean containsAttribute(String name) { return getModel().containsAttribute(name); }
ModelAndView delmav = new ModelAndView(new RedirectView("view.htm")); ModelMap delModelMap = delmav.getModelMap(); if ( delModelMap.containsAttribute("successmsg") ) { // remove from scope Map<String,Object> delModel = delmav.getModel(); delModel.remove("successmsg"); } else { String sucmsg="Deleted successfully"; delmav.addObject("successmsg", sucmsg); } return delmav;
@ModelAttribute("query") public SuggestionsPackageQuery getQuery(ModelMap model) { if (!model.containsAttribute("query")) { SuggestionsPackageQuery query = buildQuery(); model.addAttribute("query", query); } return (SuggestionsPackageQuery) model.get("query"); }
@ModelAttribute("query") public SuggestionsPackageQuery getQuery(ModelMap model){ if(!model.containsAttribute(QUERY_ATTR_NAME)){ SuggestionsPackageQuery query = new SuggestionsPackageQuery(); query.setPageSize(DEFAULT_PAGE_SIZE); query.getStatuses().add(DEFAULT_STATUS); model.addAttribute(QUERY_ATTR_NAME, query); } return (SuggestionsPackageQuery) model.get(QUERY_ATTR_NAME); }
@Override public void postHandle(HttpServletRequest request, HttpServletResponse response, Object handler, ModelAndView modelAndView) { if (response.isCommitted() || modelAndView == null || InterceptorUtils.isRedirect(modelAndView)) { return; } UserProfile userProfile = this.userBusinessService.getCurrentUserProfile(); if (userProfile != null) { String userId = userProfile.getId(); if (!modelAndView.getModelMap().containsAttribute(TabConstants.NEW_NOTIFICATION_COUNT)) { long newNotificationCount = observationService.countNewNotifications(userId); modelAndView.addObject(TabConstants.NEW_NOTIFICATION_COUNT, newNotificationCount); } } }
@ModelAttribute("query") @Secured(ConsoleSecurityRoles.ROLE_USER_VIEW) public AuthorshipQuery getQuery(ModelMap model){ if(!model.containsAttribute(QUERY_ATTR_NAME)){ AuthorshipQuery query = new AuthorshipQuery(); query.setPageSize(DEFAULT_PAGE_SIZE); query.getStatuses().add(DEFAULT_AUTH_STATUS); model.addAttribute(QUERY_ATTR_NAME, query); } return (AuthorshipQuery) model.get(QUERY_ATTR_NAME); }
private void exposeErrors(ModelMap modelMap) { if (modelMap.containsAttribute("errors")) { return; } BindException errors = new BindException(new Object(), "target"); boolean hasErrors = false; for (Object value : modelMap.values()) { if (value instanceof Errors) { for (ObjectError error : ((Errors) value).getGlobalErrors()) { errors.addError(error); hasErrors = true; } } } if (hasErrors) { modelMap.addAttribute("errors", errors); } } }
private void exposeErrors(ModelMap modelMap) { if (modelMap.containsAttribute("errors")) { return; } BindException errors = new BindException(new Object(), "target"); boolean hasErrors = false; for (Object value : modelMap.values()) { if (value instanceof Errors) { for (ObjectError error : ((Errors) value).getGlobalErrors()) { errors.addError(error); hasErrors = true; } } } if (hasErrors) { modelMap.addAttribute("errors", errors); } } }
/** * Add {@link BindingResult} attributes to the model for attributes that require it. */ private void updateBindingResult(NativeWebRequest request, ModelMap model) throws Exception { List<String> keyNames = new ArrayList<>(model.keySet()); for (String name : keyNames) { Object value = model.get(name); if (value != null && isBindingCandidate(name, value)) { String bindingResultKey = BindingResult.MODEL_KEY_PREFIX + name; if (!model.containsAttribute(bindingResultKey)) { WebDataBinder dataBinder = this.dataBinderFactory.createBinder(request, value, name); model.put(bindingResultKey, dataBinder.getBindingResult()); } } } }
/** * Add {@link BindingResult} attributes to the model for attributes that require it. */ private void updateBindingResult(NativeWebRequest request, ModelMap model) throws Exception { List<String> keyNames = new ArrayList<>(model.keySet()); for (String name : keyNames) { Object value = model.get(name); if (value != null && isBindingCandidate(name, value)) { String bindingResultKey = BindingResult.MODEL_KEY_PREFIX + name; if (!model.containsAttribute(bindingResultKey)) { WebDataBinder dataBinder = this.dataBinderFactory.createBinder(request, value, name); model.put(bindingResultKey, dataBinder.getBindingResult()); } } } }