Search in sources :

Example 96 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project opennms by OpenNMS.

the class ChooseUeisController method handleRequestInternal.

@Override
protected ModelAndView handleRequestInternal(HttpServletRequest request, HttpServletResponse response) throws Exception {
    // Pull the notice from the session
    HttpSession session = request.getSession(true);
    Notification newNotice = (Notification) session.getAttribute("newNotice");
    // If the notice is not present in the session, redirect to the first page of the wizard
    if (newNotice == null) {
        return new ModelAndView(new RedirectView(NotificationWizardServlet.SOURCE_PAGE_NOTICES));
    }
    return new ModelAndView("/admin/notification/noticeWizard/chooseUeis", "model", createModel(newNotice));
}
Also used : HttpSession(javax.servlet.http.HttpSession) ModelAndView(org.springframework.web.servlet.ModelAndView) RedirectView(org.springframework.web.servlet.view.RedirectView) Notification(org.opennms.netmgt.config.notifications.Notification)

Example 97 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project opennms by OpenNMS.

the class EventController method deleteFavorite.

public ModelAndView deleteFavorite(HttpServletRequest request, HttpServletResponse response) throws Exception {
    // delete
    String favoriteId = request.getParameter("favoriteId");
    boolean success = favoriteService.deleteFavorite(favoriteId, request.getRemoteUser());
    ModelAndView resultView = list(request, (OnmsFilterFavorite) null);
    // we deleted the favorite
    resultView.addObject("favorite", null);
    if (!StringUtils.isEmpty(request.getParameter("redirect"))) {
        // change to redirect View
        resultView.setViewName(request.getParameter("redirect"));
    }
    if (!success) {
        AlertTag.addAlertToRequest(resultView, "Favorite couldn't be deleted.", AlertType.ERROR);
    } else {
        AlertTag.addAlertToRequest(resultView, "Favorite deleted successfully.", AlertType.SUCCESS);
    }
    return resultView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 98 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project opennms by OpenNMS.

the class EventController method createListModelAndView.

private ModelAndView createListModelAndView(HttpServletRequest request, List<Filter> filterList, AcknowledgeType ackType) {
    final EventQueryParms parms = createEventQueryParms(request, filterList, ackType);
    final EventCriteria queryCriteria = new EventCriteria(parms);
    final Event[] events = m_webEventRepository.getMatchingEvents(queryCriteria);
    final ModelAndView modelAndView = new ModelAndView();
    modelAndView.addObject("events", events);
    modelAndView.addObject("parms", new NormalizedQueryParameters(parms));
    modelAndView.addObject("callback", getFilterCallback());
    modelAndView.addObject("favorites", favoriteService.getFavorites(request.getRemoteUser(), OnmsFilterFavorite.Page.EVENT).toArray());
    if (m_showEventCount) {
        EventCriteria countCriteria = new EventCriteria(filterList, ackType);
        modelAndView.addObject("eventCount", m_webEventRepository.countMatchingEvents(countCriteria));
    } else {
        modelAndView.addObject("eventCount", Integer.valueOf(-1));
    }
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) EventCriteria(org.opennms.web.event.filter.EventCriteria) NormalizedQueryParameters(org.opennms.web.filter.NormalizedQueryParameters)

Example 99 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project opennms by OpenNMS.

the class EventController method list.

private ModelAndView list(HttpServletRequest request, OnmsFilterFavorite favorite) {
    AcknowledgeType ackType = getAcknowledgeType(request);
    ModelAndView modelAndView = createListModelAndView(request, getFilterCallback().parse(request.getParameterValues("filter")), ackType);
    modelAndView.addObject("favorite", favorite);
    modelAndView.setViewName("event/list");
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView)

Example 100 with ModelAndView

use of org.springframework.web.servlet.ModelAndView in project opennms by OpenNMS.

the class EventController method index.

// index view
public ModelAndView index(HttpServletRequest request, HttpServletResponse response) throws Exception {
    List<OnmsFilterFavorite> userFilterList = favoriteService.getFavorites(request.getRemoteUser(), OnmsFilterFavorite.Page.EVENT);
    ModelAndView modelAndView = new ModelAndView("event/index");
    modelAndView.addObject("favorites", userFilterList.toArray());
    modelAndView.addObject("callback", getFilterCallback());
    return modelAndView;
}
Also used : ModelAndView(org.springframework.web.servlet.ModelAndView) OnmsFilterFavorite(org.opennms.netmgt.model.OnmsFilterFavorite)

Aggregations

ModelAndView (org.springframework.web.servlet.ModelAndView)1576 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)669 Test (org.junit.jupiter.api.Test)195 Test (org.junit.Test)188 HashMap (java.util.HashMap)166 ArrayList (java.util.ArrayList)140 RedirectView (org.springframework.web.servlet.view.RedirectView)90 Map (java.util.Map)85 List (java.util.List)69 IOException (java.io.IOException)62 PreAuthorize (org.springframework.security.access.prepost.PreAuthorize)60 Date (java.util.Date)57 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)50 MockHttpServletResponse (org.springframework.mock.web.MockHttpServletResponse)49 MockHttpServletResponse (org.springframework.web.testfixture.servlet.MockHttpServletResponse)49 MockHttpServletRequest (org.springframework.web.testfixture.servlet.MockHttpServletRequest)47 GetMapping (org.springframework.web.bind.annotation.GetMapping)45 HandlerMethod (org.springframework.web.method.HandlerMethod)45 IPerson (org.apereo.portal.security.IPerson)43 ExceptionHandler (org.springframework.web.bind.annotation.ExceptionHandler)35