List of usage examples for org.springframework.ui ModelMap ModelMap
public ModelMap()
From source file:game.kalaha.test.ModelControlTest.java
@Test public void testLogin() { ModelMap model = new ModelMap(); UserInfo userInfo = new UserInfo(); userInfo.setUsername("player1"); User dbuser = service.retrieveUser(userInfo.getUsername()); userInfo.setPassword(dbuser.getPassword()); String functionReturn = controller.login(userInfo, model); assertEquals("Valid password failt", "redirect:board.do", functionReturn); userInfo.setPassword("invalidpwd"); functionReturn = controller.login(userInfo, model); assertEquals("Invalid password was accepted", "redirect:login.do", functionReturn); }
From source file:org.ala.spatial.services.web.BreakdownController.java
@RequestMapping(value = ACTIONS_USAGE_DAY) public ModelMap usageByDay(HttpServletRequest req) { ModelMap m = new ModelMap(); m.addAttribute("breakdown", actionDao.getActionBreakdownByType()); return m;//ww w . j av a 2 s . c o m }
From source file:com.forexnepal.controller.HomeController.java
@RequestMapping(value = "/exchange_rates/currency/{currencyId}", method = RequestMethod.GET) public @ResponseBody ModelMap ExchangeRatesByCurrency(@PathVariable(value = "currencyId") int currencyId) { ModelMap map = new ModelMap(); map.addAttribute("exchangeRatesByCurrency", exchangeRatesService.getByCurency(currencyId)); return map;//from w w w. ja va2 s . c om }
From source file:com.pkrete.locationservice.admin.controller.mvc.EditSubjectMatterController.java
@RequestMapping(method = RequestMethod.POST) public ModelAndView onSubmit(HttpServletRequest request, HttpServletResponse response, @ModelAttribute("subject") SubjectMatter subjectMatter, BindingResult result) throws Exception { validator.validate(subjectMatter, result); if (result.hasErrors()) { ModelMap model = new ModelMap(); model.put("languages", getOwner(request).getLanguages()); return new ModelAndView("edit_subjectmatter", model); }/*from w ww . j ava2 s.c o m*/ subjectMatter.setUpdater(getUser(request).getUsername()); if (!subjectMattersService.update(subjectMatter)) { throw new Exception("Updating subject matter failed."); } return new ModelAndView( "redirect:subjectmatters.htm?select_subject=" + request.getParameter("select_subject")); }
From source file:org.esupportail.papercut.webportlet.EsupPapercutPortletController.java
@RequestMapping public ModelAndView renderView(RenderRequest request, RenderResponse response) { ModelMap model = new ModelMap(); model.put("htmlHeader", request.getPreferences().getValue("htmlHeader", "")); model.put("htmlFooter", request.getPreferences().getValue("htmlFooter", "")); model.put("payboxMontantMin", request.getPreferences().getValue("payboxMontantMin", "0.5")); model.put("payboxMontantMax", request.getPreferences().getValue("payboxMontantMax", "5.0")); model.put("payboxMontantStep", request.getPreferences().getValue("payboxMontantStep", "0.5")); model.put("payboxMontantDefaut", request.getPreferences().getValue("payboxMontantDefaut", "2.0")); double papercutSheetCost = Double.parseDouble(request.getPreferences().getValue("papercutSheetCost", "-1")); double papercutColorSheetCost = Double .parseDouble(request.getPreferences().getValue("papercutColorSheetCost", "-1")); String paperCutContext = request.getPreferences().getValue(PREF_PAPERCUT_CONTEXT, null); EsupPaperCutService esupPaperCutService = esupPaperCutServices.get(paperCutContext); String uid = getUid(request); String userMail = getUserMail(request); // check if the user can make a transaction int transactionNbMax = Integer.parseInt(request.getPreferences().getValue("transactionNbMax", "-1")); BigDecimal transactionMontantMax = new BigDecimal( request.getPreferences().getValue("transactionMontantMax", "-1")); boolean canMakeTransaction = true; // constraints via transactionNbMax if (transactionNbMax > -1) { long nbTransactionsNotArchived = PayboxPapercutTransactionLog .countFindPayboxPapercutTransactionLogsByUidEqualsAndPaperCutContextEqualsAndArchived(uid, paperCutContext, false); if (transactionNbMax <= nbTransactionsNotArchived) { canMakeTransaction = false;/*from www. j a va 2s . com*/ } } BigDecimal payboxMontantMin = new BigDecimal(request.getPreferences().getValue("payboxMontantMin", "0.5")); BigDecimal payboxMontantMax = new BigDecimal(request.getPreferences().getValue("payboxMontantMax", "5.0")); BigDecimal payboxMontantStep = new BigDecimal( request.getPreferences().getValue("payboxMontantStep", "0.5")); BigDecimal payboxMontantDefaut = new BigDecimal( request.getPreferences().getValue("payboxMontantDefaut", "2.0")); // constraints on the slider via transactionMontantMax if (canMakeTransaction && transactionMontantMax.intValue() > -1) { List<PayboxPapercutTransactionLog> transactionsNotArchived = PayboxPapercutTransactionLog .findPayboxPapercutTransactionLogsByUidEqualsAndPaperCutContextEqualsAndArchived(uid, paperCutContext, false) .getResultList(); BigDecimal montantTotalTransactionsNotArchived = new BigDecimal("0"); for (PayboxPapercutTransactionLog txLog : transactionsNotArchived) { montantTotalTransactionsNotArchived = montantTotalTransactionsNotArchived .add(new BigDecimal(txLog.getMontant())); } transactionMontantMax = transactionMontantMax.multiply(new BigDecimal("100")) .subtract(montantTotalTransactionsNotArchived); if (transactionMontantMax.doubleValue() < payboxMontantMax.doubleValue() * 100) { payboxMontantMax = transactionMontantMax.divide(payboxMontantStep).multiply(payboxMontantStep); payboxMontantMax = payboxMontantMax.divide(new BigDecimal("100")); if (payboxMontantDefaut.compareTo(payboxMontantMax) == 1) { payboxMontantDefaut = payboxMontantMax; } if (payboxMontantMax.compareTo(payboxMontantMin) == -1) { canMakeTransaction = false; } model.put("payboxMontantMax", payboxMontantMax.doubleValue()); model.put("payboxMontantDefaut", payboxMontantDefaut.doubleValue()); } } // generation de l'ensemble des payboxForm : payboxMontantMin -> payboxMontantMax par pas de payboxMontantStep String portletContextPath = ((RenderResponse) response).createRenderURL().toString(); Map<Integer, PayBoxForm> payboxForms = new HashMap<Integer, PayBoxForm>(); for (BigDecimal montant = payboxMontantMin; montant.compareTo(payboxMontantMax) <= 0; montant = montant .add(payboxMontantStep)) { PayBoxForm payBoxForm = esupPaperCutService.getPayBoxForm(uid, userMail, montant.doubleValue(), paperCutContext, portletContextPath); if (papercutSheetCost > 0) { int nbSheets = (int) (montant.doubleValue() / papercutSheetCost); payBoxForm.setNbSheets(nbSheets); } if (papercutColorSheetCost > 0) { int nbColorSheets = (int) (montant.doubleValue() / papercutColorSheetCost); payBoxForm.setNbColorSheets(nbColorSheets); } payboxForms.put(montant.multiply(new BigDecimal(100)).intValue(), payBoxForm); } Map<Integer, PayBoxForm> sortedMap = new TreeMap<Integer, PayBoxForm>(payboxForms); model.put("payboxForms", sortedMap); model.put("payboxMontantDefautCents", payboxMontantDefaut.multiply(new BigDecimal(100)).intValue()); model.put("canMakeTransaction", canMakeTransaction); UserPapercutInfos userPapercutInfos = esupPaperCutService.getUserPapercutInfos(uid); model.put("userPapercutInfos", userPapercutInfos); boolean isAdmin = isAdmin(request); boolean isManager = isManager(request); model.put("isAdmin", isAdmin); model.put("isManager", isManager); model.put("active", "home"); return new ModelAndView(getViewName(request, "index"), model); }
From source file:id.go.kemdikbud.tandajasa.controller.PegawaiController.java
@RequestMapping("/pegawai/daftarpegawai") public ModelMap unduhLaporan(HttpServletRequest request) { String uri = request.getRequestURI(); String format = uri.substring(uri.lastIndexOf(".") + 1); ModelMap model = new ModelMap(); model.put("format", format); model.put("tanggalCetak", new Date()); model.put("dataSource", pegawaiDao.cariSemuaPegawai()); return model; }
From source file:cz.muni.fi.mir.controllers.SourceDocumentController.java
@RequestMapping(value = { "/edit/{id}", "/edit/{id}/" }, method = RequestMethod.GET) @SiteTitle("{entity.sourceDocument.edit}") public ModelAndView editSourceDocument(@PathVariable Long id) { ModelMap mm = new ModelMap(); mm.addAttribute("sourceDocumentForm", mapper.map(sourceDocumentService.getSourceDocumentByID(id), SourceDocument.class)); return new ModelAndView("sourcedocument_edit", mm); }
From source file:es.tid.fiware.rss.controller.SettlementControllerTest.java
/** * Method to insert data before test.// w w w . j a v a 2s . co m * * @throws Exception * from dbb */ @Before public void setUp() throws Exception { databaseLoader.cleanInsert("dbunit/CREATE_DATATEST_TRANSACTIONS.xml", true); model = new ModelMap(); sessionData = new OauthLoginWebSessionData(); // prepare mockito request = Mockito.mock(HttpServletRequest.class); response = Mockito.mock(HttpServletResponse.class); session = Mockito.mock(HttpSession.class); output = Mockito.mock(ServletOutputStream.class); Mockito.when(request.getSession()).thenReturn(session); settlementManager = Mockito.mock(SettlementManager.class); ReflectionTestUtils.setField(controller, "settlementManager", settlementManager); }
From source file:org.energyos.espi.thirdparty.web.ScopeSelectionControllerTests.java
@SuppressWarnings("unchecked") @Test//from ww w . j av a 2 s . c om public void get_scopeSelection_setsScopeListModel() throws Exception { ModelMap model = new ModelMap(); controller.scopeSelection(new String[] { "scope1", "scope2" }, model); assertTrue(((List<String>) model.get("scopeList")).size() > 0); }
From source file:org.esco.portlet.accueil.portlet.PortletController.java
@RequestMapping("ABOUT") public ModelAndView renderAboutView(RenderRequest request, RenderResponse response) throws Exception { ModelMap model = new ModelMap(); return new ModelAndView("about-portlet", model); }