Example usage for org.springframework.web.servlet ModelAndView addObject

List of usage examples for org.springframework.web.servlet ModelAndView addObject

Introduction

In this page you can find the example usage for org.springframework.web.servlet ModelAndView addObject.

Prototype

public ModelAndView addObject(String attributeName, @Nullable Object attributeValue) 

Source Link

Document

Add an attribute to the model.

Usage

From source file:com.castlemock.web.basis.web.mvc.controller.configuration.ConfigurationController.java

/**
 * Retrieves all configurations and configurations groups and display them to the user
 * @return A view that displays all the configurations groups and their corresponding configurations
 *///  w w  w . j av  a2s  .c o m
@PreAuthorize("hasAuthority('ADMIN')")
@RequestMapping(method = RequestMethod.GET)
public ModelAndView defaultPage() {
    final ReadAllConfigurationGroupsOutput output = serviceProcessor
            .process(new ReadAllConfigurationGroupsInput());
    final List<ConfigurationGroupDto> configurationGroupDtos = output.getConfigurationGroups();
    final ConfigurationUpdateCommand configurationUpdateCommand = new ConfigurationUpdateCommand();
    configurationUpdateCommand.setConfigurationGroups(configurationGroupDtos);
    final ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(CONFIGURATION_UPDATE_COMMAND, configurationUpdateCommand);
    return model;
}

From source file:com.castlemock.web.mock.rest.web.mvc.controller.application.DeleteRestApplicationController.java

@PreAuthorize("hasAuthority('READER') or hasAuthority('MODIFIER') or hasAuthority('ADMIN')")
@RequestMapping(value = "/{restProjectId}/application/{restApplicationId}/delete", method = RequestMethod.GET)
public ModelAndView defaultPage(@PathVariable final String restProjectId,
        @PathVariable final String restApplicationId) {
    final ReadRestApplicationOutput ouput = serviceProcessor
            .process(new ReadRestApplicationInput(restProjectId, restApplicationId));
    ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(REST_PROJECT_ID, restProjectId);
    model.addObject(REST_APPLICATION, ouput.getRestApplication());
    return model;
}

From source file:com.castlemock.web.mock.soap.web.mvc.controller.mockresponse.SoapMockResponseController.java

/**
 * The method is responsible for retrieving a specific mocked response with a provided id
 * @param soapProjectId The id of the project which the operation belongs to
 * @param soapPortId The id of the port which the operation belongs to
 * @param soapOperationId The id of the operation that the mocked response belongs to
 * @param soapMockResponseId The id of the mocked response that should be retrieved
 * @return A view that displays the retrieved mocked response
 *//*from w  ww .  j  a  va2 s  . co m*/
@PreAuthorize("hasAuthority('READER') or hasAuthority('MODIFIER') or hasAuthority('ADMIN')")
@RequestMapping(value = "/{soapProjectId}/port/{soapPortId}/operation/{soapOperationId}/response/{soapMockResponseId}", method = RequestMethod.GET)
public ModelAndView defaultPage(@PathVariable final String soapProjectId, @PathVariable final String soapPortId,
        @PathVariable final String soapOperationId, @PathVariable final String soapMockResponseId) {
    final ReadSoapMockResponseOutput output = serviceProcessor.process(
            new ReadSoapMockResponseInput(soapProjectId, soapPortId, soapOperationId, soapMockResponseId));
    final ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(SOAP_MOCK_RESPONSE, output.getSoapMockResponse());
    model.addObject(SOAP_PROJECT_ID, soapProjectId);
    model.addObject(SOAP_PORT_ID, soapPortId);
    model.addObject(SOAP_OPERATION_ID, soapOperationId);
    model.addObject(SOAP_MOCK_RESPONSE_STATUSES, SoapMockResponseStatus.values());
    return model;
}

From source file:com.kolich.pusachat.spring.controllers.api.Index.java

@RequestMapping(method = { RequestMethod.GET, RequestMethod.HEAD })
public ModelAndView index(@RequestParam(required = false) final String key) {
    return new PusaChatControllerClosure<ModelAndView>("GET:/", logger__) {
        @Override/* w w  w.  j a v a  2 s  .co  m*/
        public ModelAndView doit() throws Exception {
            final ModelAndView mav = getModelAndView(VIEW_NAME);
            mav.addObject("key", key);
            return mav;
        }
    }.execute();
}

From source file:com.leapfrog.sms.controller.admin.CourseController.java

@RequestMapping(value = "table", method = RequestMethod.GET)
public ModelAndView table() {
    ModelAndView mv = new ModelAndView("admin/course/table");
    mv.addObject("courses", courseService.getAll());

    return mv;/*from  ww  w  .  ja  v  a  2s  .c om*/
}

From source file:com.leapfrog.sms.controller.admin.CourseController.java

@RequestMapping(value = "search", method = RequestMethod.POST)
public ModelAndView search(HttpServletRequest req) {
    ModelAndView mv = new ModelAndView("admin/course/table");
    mv.addObject("courses", courseService.search(req.getParameter("q")));

    return mv;/*  ww  w  . j  a va2 s . com*/
}

From source file:com.orchestra.portale.controller.DeletePoiController.java

@RequestMapping(value = "/deletepoi", params = "name")
public ModelAndView deletePoi(@RequestParam(value = "name") String name) {
    ModelAndView model = new ModelAndView("deleted");
    try {//from www.  j a  va  2s .  co m
        CompletePOI poi = pm.findOneCompletePoiByName(name);
        pm.deletePoi(poi);
        return model;
    } catch (RuntimeException e) {
        ModelAndView model2 = new ModelAndView("errorViewPoi");
        model2.addObject("err", "Errore impossibile trovare il poi: " + name);
        return model2;
    }
}

From source file:com.orchestra.portale.controller.DeletePoiController.java

@RequestMapping(value = "/deletepoi", params = "id")
public ModelAndView deletePoiById(@RequestParam(value = "id") String id) {
    try {/*from  w  w  w.j a v  a2s  . c  om*/
        ModelAndView model = new ModelAndView("deleted");
        CompletePOI poi = pm.getCompletePoiById(id);
        pm.deletePoi(poi);
        return model;
    } catch (RuntimeException e) {
        ModelAndView model2 = new ModelAndView("errorViewPoi");
        model2.addObject("err", "Errore impossibile trovare il poi con id: " + id);
        return model2;
    }
}

From source file:io.springagora.store.web.controllers.ProductWebController.java

/**
 * Retrieves a specific product, based on it's identifier.
 * <p>/*from ww  w.  jav a 2 s . c om*/
 * If no product is found for the given identifier, it should return an HTTP
 * 404 NOT FOUND, that is going to be handled by the default error page.
 * 
 * @param id
 *      Identifier for the product being requested by the client.
 * 
 * @return
 *      The view that must be rendered by the engine, containing the product
 *      information found for the given ID.
 */
@RequestMapping(value = "/{id}", method = RequestMethod.GET)
public ModelAndView findProductById(@PathVariable Long id) {
    Product product = Product.findOne(id);
    if (product != null) {
        ModelAndView mav = new ModelAndView("productDetails");
        mav.addObject("categories", Category.findAll());
        mav.addObject("selectedCategory", product.getCategory());
        mav.addObject("product", product);
        return mav;
    }
    throw new EntityNotFoundException("Sorry, I couldn't find this product.");
}

From source file:av1.controller.ProcessoController.java

@RequestMapping("listar-processo")
public ModelAndView listar() {
    ProcessoDAOImpl dao = new ProcessoDAOImpl();
    List<Processo> processo = dao.listar();
    ModelAndView mv = new ModelAndView("processo");
    mv.addObject("processos", processo);
    return mv;//  w  w w.j a v  a  2  s . co  m
}