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.wallride.web.controller.admin.tag.TagSearchController.java

@RequestMapping(params = "query")
public String search(@PathVariable String language, String query, Model model, SessionStatus sessionStatus,
        RedirectAttributes redirectAttributes) {
    sessionStatus.setComplete();//from  ww  w  . 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}/tags/index").query(query)
            .buildAndExpand(language).encode().toUriString();
    return "redirect:" + url;
}

From source file:org.busko.routemanager.web.admin.community.RouteSubmissionController.java

@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@Valid RouteSubmission routeSubmission, BindingResult bindingResult, Model uiModel,
        HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        populateEditForm(uiModel, routeSubmission);
        return "admin/community/routesubmissions/create";
    }/*from   w w w.jav a 2 s .c  o  m*/
    uiModel.asMap().clear();

    routeSubmission.setSubmittedDateTime(new Date());
    routeSubmission.uploadFileData();
    routeSubmission.persist();
    return "redirect:/admin/community/routesubmissions/"
            + encodeUrlPathSegment(routeSubmission.getId().toString(), httpServletRequest);
}

From source file:org.wallride.web.controller.admin.article.ArticleSearchController.java

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

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

From source file:org.wallride.web.controller.admin.page.PageSearchController.java

@RequestMapping(params = "query")
public String search(@PathVariable String language, String query, Model model, SessionStatus sessionStatus,
        RedirectAttributes redirectAttributes) {
    sessionStatus.setComplete();//www .  ja  v a2  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}/pages/index").query(query)
            .buildAndExpand(language).encode().toUriString();
    return "redirect:" + url;
}

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

@RequestMapping(value = "/{configType}_configs/{configName}/wires/{wireName}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("configType") String configType,
        @PathVariable("configName") String configName, @PathVariable("wireName") String wireName,
        @RequestParam(value = "page", required = false) Integer page,
        @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    Configuration config = Configuration.findConfigurationsByNameEquals(configName).getSingleResult();
    config.removeWire(wireName);//from w ww . ja  v a2s.  c  om
    uiModel.asMap().clear();
    uiModel.addAttribute("page", (page == null) ? "1" : page.toString());
    uiModel.addAttribute("size", (size == null) ? "10" : size.toString());
    return String.format("redirect:/%s_configs/%s/wires/", configType, configName.toString());
}

From source file:se.gothiaforum.controller.actorsform.AddImageController.java

/**
 * Renders the image form view.//from w  w  w.j  a  v a2  s . c om
 * 
 * @param model
 *            the model
 * @param request
 *            the request
 * @return the string
 */
@RenderMapping(params = "view=showImageActorsForm")
public String showImageFormView(Model model, RenderRequest request) {

    // Workaround to get the errors form-validation from action request
    Errors errors = (Errors) model.asMap().get("errors");
    if (errors != null) {
        model.addAttribute("org.springframework.validation.BindingResult.actorArticle", errors);
        return "blocks/formView";
    }

    return "blocks/imageView";
}

From source file:no.dusken.barweb.plugin.liquidityplugin.control.admin.TestAdminController.java

@Test
public void testStatus() {
    when(pluginStoreProvider.getString("valuesinbar", "0")).thenReturn("100");
    when(pluginStoreProvider.getString("valuesinbank", "0")).thenReturn("100");
    when(barPersonService.getSumPersonBalances((Gjeng) anyObject())).thenReturn(100l);

    Model model = new ExtendedModelMap();
    String view = controller.status(model);
    assertEquals("Wrong view", "no/dusken/barweb/plugin/liquidityplugin/admin/status", view);

    // bankbalance - summed balance
    assertEquals("wrong value", model.asMap().get("sum"), 100l);
    assertEquals("wrong value", model.asMap().get("valuesinbar"), 100);
    assertEquals("wrong value", model.asMap().get("valuesinbank"), 100);
    assertEquals("wrong value", model.asMap().get("sumPersonBalance"), 100l);
}

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

@RequestMapping(value = "/{configType}_configs/{configName}/reporters/{reporterName}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("configType") String configType,
        @PathVariable("configName") String configName, @PathVariable("reporterName") String reporterName,
        @RequestParam(value = "page", required = false) Integer page,
        @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    Configuration config = Configuration.findConfigurationsByNameEquals(configName).getSingleResult();
    config.removeReporter(reporterName);
    uiModel.asMap().clear();
    uiModel.addAttribute("page", (page == null) ? "1" : page.toString());
    uiModel.addAttribute("size", (size == null) ? "10" : size.toString());
    return String.format("redirect:/%s_configs/%s/reporters/", configType, configName.toString());
}

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

@RequestMapping(value = "/{configType}_configs/{configName}/matchers/{matcherName}", method = RequestMethod.DELETE, produces = "text/html")
public String delete(@PathVariable("configType") String configType,
        @PathVariable("configName") String configName, @PathVariable("matcherName") String matcherName,
        @RequestParam(value = "page", required = false) Integer page,
        @RequestParam(value = "size", required = false) Integer size, Model uiModel) {
    Configuration config = Configuration.findConfigurationsByNameEquals(configName).getSingleResult();
    config.removeMatcher(matcherName);/*  w ww.ja va2 s. c  o  m*/
    uiModel.asMap().clear();
    uiModel.addAttribute("page", (page == null) ? "1" : page.toString());
    uiModel.addAttribute("size", (size == null) ? "10" : size.toString());
    return "redirect:/{configType}_configs/" + configName.toString() + "/matchers/";
}

From source file:com.sjsu.bikelet.web.TenantLicensePolicyController.java

@RequestMapping(method = RequestMethod.POST, produces = "text/html")
public String create(@Valid TenantLicensePolicy tenantLicensePolicy, BindingResult bindingResult, Model uiModel,
        HttpServletRequest httpServletRequest) {
    validateDate(bindingResult, tenantLicensePolicy);

    if (bindingResult.hasErrors()) {
        populateEditForm(uiModel, tenantLicensePolicy);
        return "tenantlicensepolicys/create";
    }/* www  .j a  va2  s  . c  om*/
    uiModel.asMap().clear();

    try {
        tenantLicensePolicyService.saveTenantLicensePolicy(tenantLicensePolicy);
    } catch (BikeletValidationException e) {
        bindingResult.addError(new ObjectError("tenantLicensePolicy", e.getMessage()));
        if (bindingResult.hasErrors()) {
            populateEditForm(uiModel, tenantLicensePolicy);
            return "tenantlicensepolicys/create";
        }
    }

    return "redirect:/tenantlicensepolicys/"
            + encodeUrlPathSegment(tenantLicensePolicy.getId().toString(), httpServletRequest);
}