Hi,
i am using a Simple FormController and populating 2 drop-down list using referenceData.
My task is to submit a form (Email as unique field), when i submit it for the first time, i am getting my drop-down list populated properly for my select boxes,
when i fill in the form with same email id, i am getting the validation error and it does not populating the select boxes again.
can anyone point me how to go about referenceData with this kind of scenario.
My formcontroller
Code:public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, Object command, BindException errors){ logger.info("Entering HCRegistrationFormController.onSubmit method"); Map retMap = new HashMap(); try { logger.info("Reference data again"); retMap.putAll(referenceData(request)); }catch(Exception e) { logger.info("Reference data"+ e); } _healthCompassSession = request.getSession(); if(_healthCompassSession.getAttribute("currentHealthCompassConsumerId") != null){ _healthCompassSession.setAttribute("currentHealthCompassConsumerId", null); } HcUserRegistrationCommand hcUserRegistrationCommand = (HcUserRegistrationCommand) command; request.setAttribute("HcUserRegistrationCommand",hcUserRegistrationCommand); int consumerIdOfNewlyInsertedHCConsumer; try{ consumerIdOfNewlyInsertedHCConsumer = hcConsumerService.registerConsumer(hcUserRegistrationCommand); _healthCompassSession.setAttribute("currentHealthCompassConsumerId", Integer.toString(consumerIdOfNewlyInsertedHCConsumer)); } catch(DuplicateHCConsumerFoundException _duplicateHCConsumerFoundException){ logger.info("Got DuplicateHCConsumerFoundException"+_duplicateHCConsumerFoundException.getMessage()); errors.rejectValue("email", "empty.anotherUserWithSameEmail"); ModelAndView _errormodelAndView = new ModelAndView(this.errorView, errors.getModel()); _errormodelAndView.addObject("errors", errors.getAllErrors()); _errormodelAndView.addObject(retMap); return _errormodelAndView; } return new ModelAndView(getSuccessView(),retMap); } protected Map referenceData(HttpServletRequest request, Object command, Errors errors) throws Exception { logger.info("Entering HCRegistrationFormController.referenceData method"); Map referenceData = new HashMap(); referenceData.put("statesList", stateService.getAllStates()); referenceData.put("currentHealthPlanProviderList", currentHealthPlanProviderService.getAllCurrentHealthPlanProvider()); return referenceData; }
cheers
saikiran


Reply With Quote