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:net.solarnetwork.central.dras.web.DRASOperatorController.java

/**
 * Assign targets to an existing event.//from   w w w  . j av a  2 s  .  co m
 * 
 * @param request the servlet request
 * @param input input command data
 * @param model the model
 * @return view name
 */
// FIXME: remove GET support, only for testing
@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST }, value = "/assignEventTargets.*")
public String assignEventTargets(HttpServletRequest request, EventTargetsCommand input, Model model) {
    Event event = drasObserverBiz.getEvent(input.getEventId());
    SortedSet<EventTarget> sortedTargets = new TreeSet<EventTarget>(input.getTargets());
    EventTargets result = drasOperatorBiz.assignEventTargets(event, sortedTargets);
    model.asMap().clear();
    model.addAttribute(MODEL_KEY_RESULT, result);
    return WebUtils.resolveViewFromUrlExtension(request, getViewName());
}

From source file:net.solarnetwork.central.dras.web.DRASOperatorController.java

/**
 * Assign participants to an existing event.
 * // w  ww  . j  a  v  a  2  s  .  c  o m
 * @param request the servlet request
 * @param input input command data
 * @param model the model
 * @return view name
 */
// FIXME: remove GET support, only for testing
@RequestMapping(method = { RequestMethod.GET, RequestMethod.POST }, value = "/assignEventParticipants.*")
public String assignEventParticipants(HttpServletRequest request, ParticipantsCommand input, Model model) {
    Event event = drasObserverBiz.getEvent(input.getId());
    Set<Identity<Long>> participants = new LinkedHashSet<Identity<Long>>(input.getP());
    EventParticipants result = drasOperatorBiz.assignEventParticipants(event, participants);
    model.asMap().clear();
    model.addAttribute(MODEL_KEY_RESULT, result);
    return WebUtils.resolveViewFromUrlExtension(request, getViewName());
}

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

@RequestMapping(value = "/{configType}_configs/{configName}/matchers", method = RequestMethod.PUT, produces = "text/html")
public String update(@PathVariable("configType") String configType,
        @PathVariable("configName") String configName, @Valid Matcher matcher, BindingResult bindingResult,
        Model uiModel, HttpServletRequest httpServletRequest) {
    this.customValidation(configName, matcher, bindingResult);
    if (bindingResult.hasErrors()) {
        populateEditForm(uiModel, configType, configName, matcher);
        return "config_matchers/update";
    }/*from ww  w .  j  av  a  2 s. c  om*/
    uiModel.asMap().clear();
    matcher.setConfiguration(Configuration.findConfigurationsByNameEquals(configName).getSingleResult());
    matcher.merge();
    return "redirect:/{configType}_configs/" + encodeUrlPathSegment(configName, httpServletRequest)
            + "/matchers/" + encodeUrlPathSegment(matcher.getName(), httpServletRequest);
}

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

@RequestMapping(value = "/{configType}_configs/{configName}/wires", method = RequestMethod.PUT, produces = "text/html")
public String update(@PathVariable("configType") String configType,
        @PathVariable("configName") String configName, @Valid Wire wire, BindingResult bindingResult,
        Model uiModel, HttpServletRequest httpServletRequest) {
    this.customValidation(configName, wire, bindingResult);
    if (bindingResult.hasErrors()) {
        populateEditForm(uiModel, configName, wire);
        return String.format("%s_config_wires/update", configType);
    }//  www.ja  v a 2s.  co  m
    uiModel.asMap().clear();
    wire.setConfiguration(Configuration.findConfigurationsByNameEquals(configName).getSingleResult());
    wire.merge();
    return String.format("redirect:/%s_configs/", configType)
            + encodeUrlPathSegment(configName, httpServletRequest) + "/wires/"
            + encodeUrlPathSegment(wire.getName(), httpServletRequest);
}

From source file:com.wisemapping.ncontroller.MindmapController.java

@RequestMapping(value = "maps/{id}/{hid}/view", method = RequestMethod.GET)
public String showMindmapViewerRevPage(@PathVariable int id, @PathVariable int hid, @NotNull Model model)
        throws WiseMappingException {

    final String result = showMindmapEditorPage(id, model);
    model.addAttribute("readOnlyMode", true);

    // Change map XML ....
    final MindMapBean mindmapBean = (MindMapBean) model.asMap().get("mindmap");
    final MindMapHistory mindmapHistory = mindmapService.findMindmapHistory(id, hid);
    mindmapBean.getDelegated().setXml(mindmapHistory.getXml());

    return result;
}

From source file:fr.univrouen.poste.web.membre.PosteAPourvoirController.java

@RequestMapping(method = RequestMethod.POST, produces = "text/html")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_MANAGER')")
public String create(@Valid PosteAPourvoir posteAPourvoir, BindingResult bindingResult, Model uiModel,
        HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        populateEditForm(uiModel, posteAPourvoir);
        return "posteapourvoirs/create";
    }/* w w w . j  a  v a 2  s  . com*/
    uiModel.asMap().clear();
    posteAPourvoir.persist();
    return "redirect:/posteapourvoirs/"
            + encodeUrlPathSegment(posteAPourvoir.getId().toString(), httpServletRequest);
}

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

@RequestMapping(value = "/{configType}_configs/{configName}/transformers", method = RequestMethod.PUT, produces = "text/html")
public String update(@PathVariable("configType") String configType,
        @PathVariable("configName") String configName, @Valid Transformer transformer,
        BindingResult bindingResult, Model uiModel, HttpServletRequest httpServletRequest) {
    this.customValidation(configName, transformer, bindingResult);
    if (bindingResult.hasErrors()) {
        populateEditForm(uiModel, configType, configName, transformer);
        return "config_transformers/update";
    }//w ww  .ja  va2  s  . c  o  m
    uiModel.asMap().clear();
    transformer.setConfiguration(Configuration.findConfigurationsByNameEquals(configName).getSingleResult());
    transformer.merge();
    return "redirect:/{configType}_configs/" + encodeUrlPathSegment(configName, httpServletRequest)
            + "/transformers/" + encodeUrlPathSegment(transformer.getName(), httpServletRequest);
}

From source file:fr.univrouen.poste.web.membre.PosteAPourvoirController.java

@RequestMapping(method = RequestMethod.PUT, produces = "text/html")
@PreAuthorize("hasRole('ROLE_ADMIN') or hasRole('ROLE_MANAGER')")
public String update(@Valid PosteAPourvoir posteAPourvoir, BindingResult bindingResult, Model uiModel,
        HttpServletRequest httpServletRequest) {
    if (bindingResult.hasErrors()) {
        populateEditForm(uiModel, posteAPourvoir);
        return "posteapourvoirs/update";
    }/*from   w  w w  .j  a v a  2  s  .  c om*/
    uiModel.asMap().clear();

    // attention de preserver les fichiers ...
    PosteAPourvoir oldPoste = PosteAPourvoir.findPosteAPourvoir(posteAPourvoir.getId());
    posteAPourvoir.setPosteFiles(oldPoste.getPosteFiles());

    posteAPourvoir.merge();
    return "redirect:/posteapourvoirs/"
            + encodeUrlPathSegment(posteAPourvoir.getId().toString(), httpServletRequest);
}

From source file:nz.net.catalyst.mobile.dds.CapabilitySerivceControllerTest.java

@Test
public void testStatusInfo() throws Exception {
    MockHttpServletRequest request = new MockHttpServletRequest();
    Model model = new ExtendedModelMap();

    request.addHeader("user-agent",
            "Mozilla/5.0 (SymbianOS/9.2; U; Series60/3.1 NokiaE71-1/100.07.57; Profile/MIDP-2.0 Configuration/CLDC-1.1 ) AppleWebKit/413 (KHTML, like Gecko) Safari/413");

    csController.getStatusPage(request, model);

    Map<String, Object> modelMap = model.asMap();
    StatusInfo statusInfo = (StatusInfo) modelMap.get("statusinfo");
    assertTrue(StringUtils.isBlank(statusInfo.getLast_error()));

    String statusInfoStr = csController.getStatusInfo();
    assertEquals(statusInfoStr, mapper.writeValueAsString(statusInfo));
}

From source file:com.google.code.trapo.controller.ForumControllerTests.java

@Test
public void should_put_forum_in_model_when_editing_a_existent_forum() {

    Forum forum = forum();/* w ww. ja  v  a 2s  . c o  m*/
    Model model = model();

    ForumsController controller = controllerToExistentForum(forum);
    controller.edit("to edit", model);

    assertThat((Forum) model.asMap().get("forum"), equalTo(forum));
}