Package org.springframework.web.context.request

Examples of org.springframework.web.context.request.WebRequest


            // check for a URL param that overrides caching - useful for testing if this processor is incorrectly
            // caching a page (possibly due to an bad cacheKey).

            BroadleafRequestContext brc = BroadleafRequestContext.getBroadleafRequestContext();
            if (brc != null && brc.getWebRequest() != null) {
                WebRequest request = brc.getWebRequest();
                String disableCachingParam = request.getParameter("disableThymeleafTemplateCaching");
                if ("true".equals(disableCachingParam)) {
                    return false;
                }
            }
        }
View Full Code Here


        return getCustomer(new ServletWebRequest(request));
    }
   
    @Override
    public Object getCustomer() {
        WebRequest request = BroadleafRequestContext.getBroadleafRequestContext().getWebRequest();
        return getCustomer(request);
    }
View Full Code Here

        return request.getAttribute(getCustomerRequestAttributeName(), WebRequest.SCOPE_REQUEST);
    }

    @Override
    public void setCustomer(Object customer) {
        WebRequest request = BroadleafRequestContext.getBroadleafRequestContext().getWebRequest();
        request.setAttribute(getCustomerRequestAttributeName(), customer, WebRequest.SCOPE_REQUEST);
    }
View Full Code Here

    @Override
    public void onApplicationEvent(final CustomerPersistedEvent event) {
        Customer dbCustomer = event.getCustomer();

        //if there is an active request, remove the session-based customer if it exists and update CustomerState
        WebRequest request = BroadleafRequestContext.getBroadleafRequestContext().getWebRequest();
        if (request != null) {
            String customerAttribute = CustomerStateRequestProcessor.getAnonymousCustomerSessionAttributeName();
            String customerIdAttribute = CustomerStateRequestProcessor.getAnonymousCustomerIdSessionAttributeName();
            if (BLCRequestUtils.isOKtoUseSession(request)) {
                Customer sessionCustomer = (Customer) request.getAttribute(customerAttribute, WebRequest.SCOPE_GLOBAL_SESSION);
                //invalidate the session-based customer if it's there and the ID is the same as the Customer that has been
                //persisted
                if (sessionCustomer != null && sessionCustomer.getId().equals(dbCustomer.getId())) {
                    request.removeAttribute(customerAttribute, WebRequest.SCOPE_GLOBAL_SESSION);
                    request.setAttribute(customerIdAttribute, dbCustomer.getId(), WebRequest.SCOPE_GLOBAL_SESSION);
                }
            }
           
            //Update CustomerState if the persisted Customer ID is the same
            if (CustomerState.getCustomer() != null && CustomerState.getCustomer().getId().equals(dbCustomer.getId())) {
View Full Code Here

     * <p>This ensures that whatever is returned from {@link CartState#getCart()} will always be the most up-to-date
     * database version (meaning, safe to write to the DB).</p>
     */
    @Override
    public void onApplicationEvent(final OrderPersistedEvent event) {
        WebRequest request = BroadleafRequestContext.getBroadleafRequestContext().getWebRequest();
        if (request != null) {
             Order dbOrder = event.getOrder();
            //Update the cart state ONLY IF the IDs of the newly persisted order and whatever is already in CartState match
            boolean emptyCartState = CartState.getCart() == null || CartState.getCart() instanceof NullOrderImpl;
            if (emptyCartState) {
View Full Code Here

        if (BroadleafRequestContext.getBroadleafRequestContext() == null ||
                BroadleafRequestContext.getBroadleafRequestContext().getWebRequest() == null) {
            return null;
        }

        WebRequest request = BroadleafRequestContext.getBroadleafRequestContext().getWebRequest();
        return (Order) request.getAttribute(CartStateRequestProcessor.getCartRequestAttributeName(), WebRequest.SCOPE_REQUEST);
    }
View Full Code Here

     * Sets the current cart on the current request
     *
     * @param cart the new cart to set
     */
    public static void setCart(Order cart) {
        WebRequest request = BroadleafRequestContext.getBroadleafRequestContext().getWebRequest();
        request.setAttribute(CartStateRequestProcessor.getCartRequestAttributeName(), cart, WebRequest.SCOPE_REQUEST);
    }
View Full Code Here

    public void showTopicPageShouldShowListOfPostsWithUpdatedInfoAboutLastReadPosts() throws NotFoundException {
        String page = "1";
        Topic topic = createTopic();
        prepareViewTopicMocks(topic, page);

        WebRequest request = mock(WebRequest.class);

        ModelAndView mav = controller.showTopicPage(request, TOPIC_ID, page);

        verify(topicFetchService).checkViewTopicPermission(topic.getBranch().getId());
        verify(lastReadPostService).markTopicPageAsRead(topic, Integer.valueOf(page));
View Full Code Here

    public void showTopicPageShouldReturnNullIfModifiedSinceOlderThenLastUpdate() throws NotFoundException {
        String page = "1";
        Topic topic = createTopic();
        prepareViewTopicMocks(topic, page);

        WebRequest request = mock(WebRequest.class);
        doReturn(true).when(request).checkNotModified(anyLong());

        ModelAndView mav = controller.showTopicPage(request, TOPIC_ID, page);

        assertNull(mav);
View Full Code Here

    public void showTopicPageShouldReturnNotNullDataIfIfModifiedSinceOlderThenLastUpdate() throws NotFoundException {
        String page = "1";
        Topic topic = createTopic();
        prepareViewTopicMocks(topic, page);

        WebRequest request = mock(WebRequest.class);
        when(request.checkNotModified(topic.getModificationDate().getMillis())).thenReturn(false);

        ModelAndView mav = controller.showTopicPage(request, TOPIC_ID, page);

        assertNotNull(mav);
    }
View Full Code Here

TOP

Related Classes of org.springframework.web.context.request.WebRequest

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.