Search in sources :

Example 6 with BindingAwareModelMap

use of org.springframework.validation.support.BindingAwareModelMap in project alf.io by alfio-event.

the class ReservationFlowIntegrationTest method assignTicket.

private void assignTicket(String eventName, String reservationIdentifier, String ticketIdentifier, String firstName, String lastName) throws Exception {
    UpdateTicketOwnerForm ticketOwnerForm = new UpdateTicketOwnerForm();
    ticketOwnerForm.setFirstName(firstName);
    ticketOwnerForm.setLastName(lastName);
    ticketOwnerForm.setEmail("testmctest@test.com");
    ticketOwnerForm.setUserLanguage("en");
    Assert.assertTrue(reservationController.assignTicketToPerson(eventName, reservationIdentifier, ticketIdentifier, ticketOwnerForm, Mockito.mock(BindingResult.class), new MockHttpServletRequest(), new BindingAwareModelMap()).endsWith("/success"));
}
Also used : BindingResult(org.springframework.validation.BindingResult) BeanPropertyBindingResult(org.springframework.validation.BeanPropertyBindingResult) MockHttpServletRequest(org.springframework.mock.web.MockHttpServletRequest) BindingAwareModelMap(org.springframework.validation.support.BindingAwareModelMap) UpdateTicketOwnerForm(alfio.controller.form.UpdateTicketOwnerForm)

Example 7 with BindingAwareModelMap

use of org.springframework.validation.support.BindingAwareModelMap in project com.revolsys.open by revolsys.

the class WebAnnotationMethodHandlerAdapter method invokeHandlerMethod.

protected ModelAndView invokeHandlerMethod(final HttpServletRequest request, final HttpServletResponse response, final Object handler) throws Exception {
    final AnnotationHandlerMethodResolver methodResolver = getMethodResolver(handler);
    final WebMethodHandler handlerMethod = methodResolver.resolveHandlerMethod(request);
    final ServletWebRequest webRequest = new ServletWebRequest(request, response);
    final RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    try {
        RequestContextHolder.setRequestAttributes(webRequest);
        final ExtendedModelMap implicitModel = new BindingAwareModelMap();
        final Object result = handlerMethod.invokeMethod(handler, request, response);
        if (result == null) {
            return null;
        } else {
            final ModelAndView mav = getModelAndView(handlerMethod.getMethod(), handler.getClass(), result, implicitModel, webRequest);
            return mav;
        }
    } finally {
        RequestContextHolder.setRequestAttributes(requestAttributes);
    }
}
Also used : ExtendedModelMap(org.springframework.ui.ExtendedModelMap) ModelAndView(org.springframework.web.servlet.ModelAndView) BindingAwareModelMap(org.springframework.validation.support.BindingAwareModelMap) RequestAttributes(org.springframework.web.context.request.RequestAttributes) ServletWebRequest(org.springframework.web.context.request.ServletWebRequest)

Aggregations

BindingAwareModelMap (org.springframework.validation.support.BindingAwareModelMap)7 MockHttpServletRequest (org.springframework.mock.web.MockHttpServletRequest)6 Model (org.springframework.ui.Model)4 BeanPropertyBindingResult (org.springframework.validation.BeanPropertyBindingResult)4 BindingResult (org.springframework.validation.BindingResult)4 ServletWebRequest (org.springframework.web.context.request.ServletWebRequest)3 RedirectAttributes (org.springframework.web.servlet.mvc.support.RedirectAttributes)3 RedirectAttributesModelMap (org.springframework.web.servlet.mvc.support.RedirectAttributesModelMap)3 SerializablePair (alfio.controller.api.admin.SerializablePair)2 PaymentForm (alfio.controller.form.PaymentForm)2 ReservationForm (alfio.controller.form.ReservationForm)2 UpdateTicketOwnerForm (alfio.controller.form.UpdateTicketOwnerForm)2 TicketDecorator (alfio.controller.support.TicketDecorator)2 TicketReservationModification (alfio.model.modification.TicketReservationModification)2 Principal (java.security.Principal)2 Pair (org.apache.commons.lang3.tuple.Pair)2 TestConfiguration (alfio.TestConfiguration)1 DataSourceConfiguration (alfio.config.DataSourceConfiguration)1 Initializer (alfio.config.Initializer)1 RepositoryConfiguration (alfio.config.RepositoryConfiguration)1