Package grails.web.mvc

Examples of grails.web.mvc.FlashScope


            return null;
        }

        HttpServletRequest servletRequest = (HttpServletRequest) request;
        HttpSession session = servletRequest.getSession(false);
        FlashScope fs;
        if (session != null) {
            fs = (FlashScope)session.getAttribute(FLASH_SCOPE);
        }
        else {
            fs = (FlashScope)request.getAttribute(FLASH_SCOPE);
View Full Code Here


    private static final String ERRORS_PROPERTY = "errors";

    public void testPutNull() {
        GrailsWebMockUtil.bindMockWebRequest();

        FlashScope fs = new GrailsFlashScope();
        fs.put("test",null);
    }
View Full Code Here

    public void testNextState() {

        GrailsWebMockUtil.bindMockWebRequest();

        FlashScope fs = new GrailsFlashScope();
        fs.put("test","value");
        fs.put("fred","flintstone");
        fs.getNow().put("barney", "rubble");

        assertFalse(fs.isEmpty());
        assertEquals("flintstone",fs.get("fred"));
        assertEquals("rubble",fs.get("barney"));
        assertEquals(3, fs.size());
        assertTrue(fs.containsKey("test"));
        assertTrue(fs.containsKey("barney"));
        assertTrue(fs.containsValue("value"));
        assertFalse(fs.containsKey("wilma"));

        // the state immediately following this one the map should still contain the previous entries
        fs.next();

        assertFalse(fs.isEmpty());
        assertEquals("flintstone",fs.get("fred"));
        assertEquals(2, fs.size());
        assertTrue(fs.containsKey("test"));
        assertTrue(fs.containsValue("value"));
        assertFalse(fs.containsKey("wilma"));

        // the next state it should be empty
        fs.next();

        assertTrue(fs.isEmpty());
        assertEquals(0,fs.size());
    }
View Full Code Here

        map.put("barney","rabble");
        MetaClass mc = GroovySystem.getMetaClassRegistry().getMetaClass(value.getClass());
        mc.setProperty(value, ERRORS_PROPERTY, new Object());

        //put the map to scope
        FlashScope fs = new GrailsFlashScope();
        fs.put("test", "value");
        fs.put("flinstones", map);

        assertFalse(fs.isEmpty());
        assertEquals(2, fs.size());
        assertEquals(map,fs.get("flinstones"));
        assertEquals("value", fs.get("test"));

        // the state immediately following this one the map should still contain the previous entries
        fs.next();

        assertFalse(fs.isEmpty());
        assertEquals(2, fs.size());
        assertEquals(map,fs.get("flinstones"));
        assertEquals("value", fs.get("test"));

        // the next state it should be empty
        fs.next();

        assertTrue(fs.isEmpty());
        assertEquals(0,fs.size());
    }
View Full Code Here

            WebUtils.storeGrailsWebRequest(webRequest);

            // Set the flash scope instance to its next state. We do
            // this here so that the flash is available from Grails
            // filters in a valid state.
            FlashScope fs = webRequest.getAttributes().getFlashScope(request);
            fs.next();

            // Pass control on to the next filter (or the servlet if
            // there are no more filters in the chain).
            filterChain.doFilter(request, response);
        }
View Full Code Here

TOP

Related Classes of grails.web.mvc.FlashScope

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.