Example usage for org.springframework.ui Model asMap

List of usage examples for org.springframework.ui Model asMap

Introduction

In this page you can find the example usage for org.springframework.ui Model asMap.

Prototype

Map<String, Object> asMap();

Source Link

Document

Return the current set of model attributes as a Map.

Usage

From source file:org.kew.rmf.matchconf.web.DictionaryController.java

@RequestMapping(value = "/{name}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("name") String name,
        @RequestParam(value = "page", required = false) Integer page,
        @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    Dictionary dictionary = Dictionary.findDictionariesByNameEquals(name).getSingleResult();
    dictionary.remove();//from w ww.j  ava 2s. com
    uiModel.asMap().clear();
    uiModel.addAttribute("page", (page == null) ? "1" : page.toString());
    uiModel.addAttribute("size", (size == null) ? "10" : size.toString());
    return "redirect:/dictionaries";
}

From source file:uk.ac.ebi.emma.controller.AlleleManagementListController.java

/**
 * 'Go' button implementation/* w w w . ja v  a 2  s  . co  m*/
 * 
 * @param model the data model
 * @return the view to show
 */
@RequestMapping(value = "/go", method = RequestMethod.GET)
public String go(Model model) {
    // Get the filter, then re-add it to the model.
    Map modelMap = model.asMap();
    Filter filter = (Filter) modelMap.get("filter");
    model.addAttribute("filter", filter);

    List<Allele> filteredAllelesList = allelesManager.getFilteredAllelesList(filter);
    model.addAttribute("filteredAllelesList", filteredAllelesList);
    model.addAttribute("showResultsForm", true);
    model.addAttribute("resultsCount", filteredAllelesList.size());

    return "alleleManagementList";
}

From source file:org.fenixedu.ulisboa.integration.sas.ui.spring.controller.SasBaseController.java

protected String redirect(String destinationAction, Model model, RedirectAttributes redirectAttributes) {
    if (model.containsAttribute(INFO_MESSAGES)) {
        redirectAttributes.addFlashAttribute(INFO_MESSAGES, model.asMap().get(INFO_MESSAGES));
    }//from  ww  w  .  j  a v a  2s .co  m
    if (model.containsAttribute(WARNING_MESSAGES)) {
        redirectAttributes.addFlashAttribute(WARNING_MESSAGES, model.asMap().get(WARNING_MESSAGES));
    }
    if (model.containsAttribute(ERROR_MESSAGES)) {
        redirectAttributes.addFlashAttribute(ERROR_MESSAGES, model.asMap().get(ERROR_MESSAGES));
    }

    return "redirect:" + destinationAction;
}

From source file:com.comcast.video.dawg.controller.park.PopulateControllerTest.java

@SuppressWarnings("unchecked")
@Test//from   w w  w .  j a  v a2 s .co m
public void testPopulateWithModel() {
    PopulateController controller = new PopulateController();
    ParkService mockParkService = new MockParkService();
    ChimpsToken myToken = new ChimpsToken("mytoken");
    mockParkService.saveToken(myToken);
    ReflectionTestUtils.setField(controller, "parkService", mockParkService);
    Model model = new BindingAwareModelMap();
    Assert.assertEquals(controller.populate(model), "populate");
    List<ChimpsToken> tokens = (List<ChimpsToken>) model.asMap().get("population");
    Assert.assertNotNull(tokens);
    Assert.assertTrue(tokens.contains(myToken));
}

From source file:org.wallride.web.controller.admin.customfield.CustomFieldSearchController.java

@RequestMapping(params = "query")
public String search(@PathVariable String language, String query, Model model, SessionStatus sessionStatus,
        RedirectAttributes redirectAttributes) {
    sessionStatus.setComplete();/*ww w .  ja  va  2 s.  c  o m*/

    for (Map.Entry<String, Object> mapEntry : model.asMap().entrySet()) {
        redirectAttributes.addFlashAttribute(mapEntry.getKey(), mapEntry.getValue());
    }
    String url = UriComponentsBuilder.fromPath("/_admin/{language}/customfields/index").query(query)
            .buildAndExpand(language).encode().toUriString();
    return "redirect:" + url;
}

From source file:com.qubit.solution.fenixedu.bennu.webservices.ui.management.keystores.DomainKeyStoreController.java

private DomainKeyStore getDomainKeyStore(Model m) {
    return (DomainKeyStore) m.asMap().get("domainKeyStore");
}

From source file:org.opentravel.pubs.controllers.BaseController.java

/**
 * Adds the given set of validation results to the model provided.  If any validation
 * results already exist in the model, the new results are merged into the original set.
 * //  w w w  .  j av a2s. c o m
 * <p>The results are stored as a model attribute under the key "validationErrors".
 * 
 * <p>A call to this method also marks the current transaction for rollback.
 * 
 * @param validationResults  the set of validation results to add
 * @param model  the model that will contain the validation results
 */
protected void addValidationErrors(ValidationResults validationResults, Model model) {
    if (validationResults != null) {
        ValidationResults existingResults = (ValidationResults) model.asMap().get("validationErrors");

        if (existingResults != null) {
            existingResults.addAll(validationResults);

        } else {
            model.addAttribute("validationErrors", validationResults);
        }
    }
}

From source file:org.wallride.web.controller.admin.user.UserSearchController.java

@RequestMapping(params = "query")
public String search(@PathVariable String language, String query, Model model, SessionStatus sessionStatus,
        RedirectAttributes redirectAttributes) {
    sessionStatus.setComplete();/*from   w  ww  . j  a  v a 2  s.  c o m*/

    for (Map.Entry<String, Object> mapEntry : model.asMap().entrySet()) {
        redirectAttributes.addFlashAttribute(mapEntry.getKey(), mapEntry.getValue());
    }
    String url = UriComponentsBuilder.fromPath("/_admin/{language}/users/index").query(query)
            .buildAndExpand(language).encode().toUriString();
    return "redirect:" + url;
}

From source file:org.duracloud.account.app.controller.AccountInfoController.java

@Transactional
@RequestMapping(value = INFO_EDIT_MAPPING, method = RequestMethod.POST)
public ModelAndView editInfo(@PathVariable Long accountId,
        @ModelAttribute(EDIT_ACCOUNT_INFO_FORM_KEY) @Valid AccountEditForm accountEditForm,
        BindingResult result, Model model) throws AccountNotFoundException, DBNotFoundException {

    log.info("editInfo account {}", accountId);

    if (result.hasErrors()) {
        return new ModelAndView(ACCOUNT_INFO_EDIT_ID, model.asMap());
    }/*from  ww  w. j  a v a 2 s. c  om*/

    getAccountManagerService().getAccount(accountId).storeAccountInfo(accountEditForm.getAcctName(),
            accountEditForm.getOrgName(), accountEditForm.getDepartment());

    return createAccountRedirectModelAndView(accountId, AccountDetailsController.ACCOUNT_DETAILS_PATH);

}

From source file:org.wallride.web.controller.admin.comment.CommentSearchController.java

@RequestMapping(params = "query")
public String query(@PathVariable String language, String query, Model model, SessionStatus sessionStatus,
        RedirectAttributes redirectAttributes) {
    sessionStatus.setComplete();/*w ww . java 2  s .c om*/

    for (Map.Entry<String, Object> mapEntry : model.asMap().entrySet()) {
        redirectAttributes.addFlashAttribute(mapEntry.getKey(), mapEntry.getValue());
    }
    String url = UriComponentsBuilder.fromPath("/_admin/{language}/comments/index").query(query)
            .buildAndExpand(language).encode().toUriString();
    return "redirect:" + url;
}