List of usage examples for org.springframework.validation BindException getModel
@Override
public Map<String, Object> getModel()
From source file:org.mifos.ui.client.controller.CreateClientController.java
@Override protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) { Map<String, Object> model = errors.getModel(); model.put("datePattern", localDateEditor.getDatePattern()); model.put("client", new ClientDto()); return new ModelAndView("createClient", model); }
From source file:org.mifos.ui.loan.controller.DeleteLoanProductController.java
@Override protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) { Map<String, Object> model = errors.getModel(); Integer loanProductId = Integer.valueOf(request.getParameter("id")); LoanProductDto loanProduct = loanProductService.getLoanProduct(loanProductId); model.put("loanProduct", loanProduct); return new ModelAndView("deleteLoanProduct", model); }
From source file:org.tsm.concharto.web.flagevent.FlagEventController.java
@SuppressWarnings("unchecked") @Override//from w w w. java2 s . c o m protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { Map model = errors.getModel(); model.put(MODEL_DISPOSITIONS, Flag.DISPOSITION_CODES); model.put(MODEL_REASONS, Flag.REASON_CODES); changeHistoryControllerHelper.doProcess(Event.class, "edit/flagevent.htm", request, model, PAGE_SIZE); return new ModelAndView().addAllObjects(model); }
From source file:org.tsm.concharto.web.member.SettingsController.java
@SuppressWarnings("unchecked") @Override/*from w w w .j av a 2s.com*/ protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { Map model = errors.getModel(); SettingsForm settingsForm = (SettingsForm) command; //TODO fix this we are getting the user three times from the database! //Once in formBackingObject and once showForm and now here. User user = userDao .find((String) WebUtils.getSessionAttribute(request, AuthConstants.SESSION_AUTH_USERNAME)); //the user can choose to fill out none or all of the password fields //if they don't enter any password fields, we don't need to validate them boolean passwordChanged = false; if (!SettingsFormValidator.allPasswordFieldsAreEmpty(settingsForm)) { passwordChanged = true; //ok we have to validate the original password if (!PasswordUtil.isPasswordValid(settingsForm.getExistingPassword(), user.getPassword())) { //tell the user there was a problem and let the default form handle the rest errors.rejectValue("existingPassword", "invalidUserPasswd.authForm.existingPassword"); model.put(MODEL_USER, safeUser(user)); model.put(MODEL_SUCCESS, false); return new ModelAndView(getFormView(), model); } } if (user != null) { //ok we can change the information if (passwordChanged) { user.setPassword(PasswordUtil.encrypt(settingsForm.getPassword())); } user.setEmail(settingsForm.getEmail()); userDao.save(user); model.put(MODEL_SUCCESS, true); model.put(MODEL_USER, safeUser(user)); } return new ModelAndView(getSuccessView(), model); }
From source file:org.tsm.concharto.web.edit.EventController.java
@SuppressWarnings("unchecked") @Override/*from ww w .ja v a 2 s. c o m*/ protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors) throws Exception { Map model = errors.getModel(); addAccuracies(model); return new ModelAndView(getFormView(), model); }
From source file:org.tsm.concharto.web.member.SettingsController.java
@SuppressWarnings("unchecked") @Override/*from ww w.j a v a 2 s . c om*/ protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors, Map controlModel) throws Exception { //get the user object so we can show it to them Map model = errors.getModel(); User user = userDao .find((String) WebUtils.getSessionAttribute(request, AuthConstants.SESSION_AUTH_USERNAME)); if (user != null) { //user can be null when navigating directly to this page without logging in. //It shouldn't normally happen model.put(MODEL_USER, safeUser(user)); } return new ModelAndView(getFormView(), model); }
From source file:org.tsm.concharto.web.home.HomeController.java
@SuppressWarnings("unchecked") @Override/* ww w .j a va2 s . com*/ protected ModelAndView showForm(HttpServletRequest request, HttpServletResponse response, BindException errors, Map controlModel) throws Exception { Map model = errors.getModel(); model.put(MODEL_RECENT_EVENTS, eventDao.findRecent(CatalogUtil.getCatalog(request), MAX_RECENT_EVENTS, 0)); model.put(MODEL_TOTAL_EVENTS, eventDao.getTotalCount(CatalogUtil.getCatalog(request))); //The index is so large that we don't normally want to send all of that data //in the HTTP message, so we only setup the index if the user selected 'index' tab. //So only show the index when the URL is index.htm //Also, when that happens, we don't want to increment the spotlight if (StringUtils.contains(request.getRequestURI(), INDEX_URI)) { setupTagIndex(request, model); //tell the jsp view that this is the index page. Apparently, you can't count on the jsp //knowing the real URL because it things the url is the name of the jsp page, not the //spring binding. E.g. Even if we got to the jsp page via index.htm, the jsp //${pageContext.request.requestURI} will say "/home/home.jsp" instead of "index.htm" //since we need to notify the jsp view to display things for index instead of home request.setAttribute(PARAM_IS_INDEX, true); //clicked on the index tab, so we don't need to increment the spotlight setupSpotlight(request, model, false); } else { setupSpotlight(request, model, true); } setupTagCloud(request, model); // clear out the eventSearchForm session if there is one WebUtils.setSessionAttribute(request, SearchHelper.SESSION_EVENT_SEARCH_FORM, null); return new ModelAndView(getFormView(), model); }
From source file:org.mifos.ui.loan.controller.DeleteLoanProductController.java
@Override @SuppressWarnings("PMD.SignatureDeclareThrowsException") // signature of superclass method protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { DeleteLoanProductDto deleteLoanProductDto = (DeleteLoanProductDto) command; ModelAndView result = null;/*from ww w.j av a 2 s . co m*/ Map<String, Object> model = errors.getModel(); if ("Delete".equals(deleteLoanProductDto.getAction())) { LoanProductDto loanProductDto = loanProductService .getLoanProduct(((DeleteLoanProductDto) command).getLoanProductId()); model.put("loanProduct", loanProductDto); try { loanProductService.deleteLoanProduct(loanProductDto); result = new ModelAndView("deleteLoanProductSuccess", "model", model); } catch (MifosException e) { result = new ModelAndView("deleteLoanProductFailure", "model", model); } } else { result = new ModelAndView("adminHome"); } return result; }
From source file:org.tsm.concharto.web.discuss.DiscussController.java
@Override protected ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { //save the wikitext WikiTextForm discussion = (WikiTextForm) command; if (discussion.getShowPreview()) { return new ModelAndView(getFormView(), errors.getModel()); } else {/*from w ww.j a va 2 s. c om*/ //post process macros. Later we will probably do something fancier for general macros. String substituted = SubstitutionMacro.postSignature(request, discussion.getEvent().getDiscussion().getText()); discussion.getEvent().getDiscussion().setText(substituted); //this isn't new we just need to save the discussion eventDao.saveOrUpdate(discussion.getEvent()); return super.onSubmit(request, response, command, errors); } }
From source file:org.tsm.concharto.web.edit.EventController.java
@SuppressWarnings("unchecked") @Override// w ww. java2 s. c o m protected ModelAndView processFormSubmission(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors) throws Exception { EventForm eventForm = (EventForm) command; Map model = errors.getModel(); if (BooleanUtils.isTrue(eventForm.getShowPreview())) { Event event = EventFormFactory.createEvent(eventForm); EventFormFactory.renderWiki(event, request); //for processing the drop down selector for positional accuracies addAccuracies(model); if (null != event.getPositionalAccuracy()) { event.setPositionalAccuracy( (PositionalAccuracy) eventDao.getPositionalAccuracy(event.getPositionalAccuracy().getId())); } eventForm.setPreviewEvent(JSONFormat.toJSON(event)); return new ModelAndView(getFormView(), model); } else if (errors.hasErrors()) { addAccuracies(model); return new ModelAndView(getFormView(), model); } else { //change the map center of the search form to wherever we are now! EventSearchForm eventSearchForm = getEventSearchForm(request); if (eventSearchForm == null) { eventSearchForm = new EventSearchForm(); } //now create or update the event Event event; if (eventForm.getEventId() != null) { //get the event from the session event = (Event) WebUtils.getSessionAttribute(request, SESSION_EVENT); event = EventFormFactory.updateEvent(event, eventForm); } else { event = EventFormFactory.createEvent(eventForm); } //get the catalog from the URL event.setCatalog(CatalogUtil.getCatalog(request)); this.eventDao.saveOrUpdate(event); //update the tag cloud this.tagAggregateService.refreshRecent(CatalogUtil.getCatalog(request)); //update the session eventSearchForm.setDisplayEventId(event.getId()); //we want to show only the event we've just edited WebUtils.setSessionAttribute(request, SESSION_EVENT, event); WebUtils.setSessionAttribute(request, SearchHelper.SESSION_EVENT_SEARCH_FORM, eventSearchForm); WebUtils.setSessionAttribute(request, SearchHelper.SESSION_DO_SEARCH_ON_SHOW, true); return new ModelAndView(getSuccessView()); } }