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.leapfrog.lfaeventmanager.admin.controller.EventListController.java

@RequestMapping(value = "index", method = RequestMethod.GET)
public ModelAndView index() {
    ModelAndView mv = new ModelAndView("eventlist/index");
    mv.addObject("eventLists", eventListService.getAll());
    return mv;// w w w.j  a  v a  2  s  . c  om
}

From source file:it.geosolutions.geobatch.ui.mvc.FlowManagerPauseController.java

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response)
        throws Exception {
    Catalog catalog = (Catalog) getApplicationContext().getBean("catalog");

    String fmId = request.getParameter("fmId");
    String fullPause = request.getParameter("full");
    boolean full = "true".equals(fullPause);

    if (fmId != null) {
        FileBasedFlowManager fm = catalog.getResource(fmId, FileBasedFlowManager.class);

        if ((fm != null) && fm.isRunning()) {
            fm.pause(full);/*from ww  w  . j a  v a 2 s. co  m*/
        }
    }

    ModelAndView mav = new ModelAndView("flows");
    mav.addObject("flowManagers", catalog.getFlowManagers(FileBasedFlowManager.class));

    return mav;
}

From source file:org.perconsys.controllers.PostManagementController.java

@RequestMapping(value = "/create", method = RequestMethod.GET)
public ModelAndView create() {
    Post post = new Post();
    String blogId = getRequest().getParameter("blog");
    ModelAndView model = new ModelAndView("post/form", "post", post);
    model.addObject("blogId", blogId);
    return model;
}

From source file:springku.BelajarController.java

@RequestMapping(value = "/css")
public ModelAndView css() {
    ModelAndView view = new ModelAndView("learning");
    view.addObject("pesan", "emi");
    return view;/*from   w  w w.ja v a 2  s  .co  m*/
}

From source file:com.cami.web.controller.LeController.java

@RequestMapping(value = "/welcome**", method = RequestMethod.GET)
public ModelAndView welcomePage() {

    Authentication auth = SecurityContextHolder.getContext().getAuthentication();
    String name = auth.getName(); //get logged in username
    final Role user = roleService.retrieveAUser(name);
    final Role userConnected = roleService.retrieveAUser(name);
    ModelAndView model = new ModelAndView();
    model.addObject("user", user);
    model.addObject("userConnected", userConnected);
    model.setViewName("hello");
    return model;

}

From source file:com.castlemock.web.mock.rest.web.mvc.controller.resource.CreateRestResourceController.java

@PreAuthorize("hasAuthority('MODIFIER') or hasAuthority('ADMIN')")
@RequestMapping(value = "/{projectId}/application/{applicationId}/create/resource", method = RequestMethod.GET)
public ModelAndView defaultPage(@PathVariable final String projectId,
        @PathVariable final String applicationId) {
    final RestResourceDto restResourceDto = new RestResourceDto();
    restResourceDto.setUri(SLASH);// w w w .ja v  a2 s  .  c  om
    final ModelAndView model = createPartialModelAndView(PAGE);
    model.addObject(REST_PROJECT_ID, projectId);
    model.addObject(REST_APPLICATION_ID, applicationId);
    model.addObject(REST_RESOURCE, restResourceDto);
    return model;
}

From source file:com.museum_web.controller.AnnotationController.java

@RequestMapping("/annotation")
public ModelAndView list() {
    List<Annotation> annotations = as.listAnnotations();
    List<Museum> museums = (ArrayList<Museum>) new MuseumService().listMuseum();
    List<MuseologicalObject> objects = (ArrayList<MuseologicalObject>) new MuseologicalObjectService()
            .listObjects();//from ww  w . j av a 2 s .com
    annotations = new AnnotationService().listAnnotations();
    ModelAndView mv = new ModelAndView("annotation/list");
    mv.addObject("lista", annotations);
    mv.addObject("museums", museums);
    mv.addObject("objects", objects);
    return mv;

}

From source file:com.tce.oauth2.spring.client.controller.TodoController.java

@RequestMapping("/todos")
public ModelAndView index(HttpServletRequest request) {
    List<Todo> todos = todoService.findByUsername((String) request.getSession().getAttribute("access_token"),
            (String) request.getSession().getAttribute("username"));
    ModelAndView model = new ModelAndView();
    model.addObject("todo", new Todo());
    model.addObject("todos", todos);
    model.setViewName("todolist");
    return model;
}

From source file:org.androidpn.server.console.controller.HistoryController.java

public ModelAndView list(HttpServletRequest request, HttpServletResponse response) throws Exception {
    String currentPage = request.getParameter("currentPage");
    int pageSize = 5;
    Page<NotificationMO> historyPageList = new Page<NotificationMO>(pageSize);//7??
    if (currentPage == null || Integer.parseInt(currentPage) < 0) {
        currentPage = "1";
    }/*w  ww .  ja v  a  2  s  .  co m*/
    historyPageList.setPageNo(Integer.parseInt(currentPage));//1?
    ServiceLocator.getNotificationService().queryNotification(historyPageList);
    historyPageList.setHtmlPage(historyPageList, "/Androidapn/history.do?");
    ModelAndView mv = new ModelAndView();
    mv.addObject("historyPageList", historyPageList);

    List<NotificationMO> historyList = new ArrayList<NotificationMO>();
    if (historyPageList.getResults() != null) {
        for (NotificationMO notificationMO : historyPageList.getResults()) {
            historyList.add(notificationMO);
        }
    }
    mv.addObject("historyList", historyList);
    mv.setViewName("history/list");
    return mv;
}

From source file:org.owasp.webgoat.controller.Login.java

/**
 * <p>login.</p>/*from w  w  w.  ja  v  a  2  s . c  om*/
 *
 * @param error a {@link java.lang.String} object.
 * @param logout a {@link java.lang.String} object.
 * @return a {@link org.springframework.web.servlet.ModelAndView} object.
 */
@RequestMapping(value = "login.mvc", method = RequestMethod.GET)
public ModelAndView login(@RequestParam(value = "error", required = false) String error,
        @RequestParam(value = "logout", required = false) String logout) {

    ModelAndView model = new ModelAndView();
    if (error != null) {
        model.addObject("error", "Invalid username and password!");
    }

    if (logout != null) {
        model.addObject("msg", "You've been logged out successfully.");
    }
    model.setViewName("login");

    return model;

}