Search in sources :

Example 1 with ServletRequest

use of org.apache.tiles.request.servlet.ServletRequest in project spring-framework by spring-projects.

the class TilesConfigurerTests method simpleBootstrap.

@Test
public void simpleBootstrap() {
    MockServletContext servletContext = new MockServletContext();
    TilesConfigurer tc = new TilesConfigurer();
    tc.setDefinitions("/org/springframework/web/servlet/view/tiles3/tiles-definitions.xml");
    tc.setCheckRefresh(true);
    tc.setServletContext(servletContext);
    tc.afterPropertiesSet();
    ApplicationContext tilesContext = ServletUtil.getApplicationContext(servletContext);
    BasicTilesContainer container = (BasicTilesContainer) TilesAccess.getContainer(tilesContext);
    Request requestContext = new ServletRequest(container.getApplicationContext(), new MockHttpServletRequest(), new MockHttpServletResponse());
    assertNotNull(container.getDefinitionsFactory().getDefinition("test", requestContext));
    tc.destroy();
}
Also used : ServletRequest(org.apache.tiles.request.servlet.ServletRequest) MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) ApplicationContext(org.apache.tiles.request.ApplicationContext) MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) BasicTilesContainer(org.apache.tiles.impl.BasicTilesContainer) ServletRequest(org.apache.tiles.request.servlet.ServletRequest) Request(org.apache.tiles.request.Request) MockHttpServletRequest(org.springframework.mock.web.test.MockHttpServletRequest) MockServletContext(org.springframework.mock.web.test.MockServletContext) MockHttpServletResponse(org.springframework.mock.web.test.MockHttpServletResponse) Test(org.junit.Test)

Example 2 with ServletRequest

use of org.apache.tiles.request.servlet.ServletRequest in project spring-framework by spring-projects.

the class TilesView method checkResource.

@Override
public boolean checkResource(final Locale locale) throws Exception {
    HttpServletRequest servletRequest = null;
    RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    if (requestAttributes instanceof ServletRequestAttributes) {
        servletRequest = ((ServletRequestAttributes) requestAttributes).getRequest();
    }
    Request request = new ServletRequest(this.applicationContext, servletRequest, null) {

        @Override
        public Locale getRequestLocale() {
            return locale;
        }
    };
    return this.renderer.isRenderable(getUrl(), request);
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequest(org.apache.tiles.request.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) AbstractRequest(org.apache.tiles.request.AbstractRequest) ServletRequest(org.apache.tiles.request.servlet.ServletRequest) HttpServletRequest(javax.servlet.http.HttpServletRequest) Request(org.apache.tiles.request.Request) ServletRequestAttributes(org.springframework.web.context.request.ServletRequestAttributes) RequestAttributes(org.springframework.web.context.request.RequestAttributes)

Aggregations

Request (org.apache.tiles.request.Request)2 ServletRequest (org.apache.tiles.request.servlet.ServletRequest)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 BasicTilesContainer (org.apache.tiles.impl.BasicTilesContainer)1 AbstractRequest (org.apache.tiles.request.AbstractRequest)1 ApplicationContext (org.apache.tiles.request.ApplicationContext)1 Test (org.junit.Test)1 MockHttpServletRequest (org.springframework.mock.web.test.MockHttpServletRequest)1 MockHttpServletResponse (org.springframework.mock.web.test.MockHttpServletResponse)1 MockServletContext (org.springframework.mock.web.test.MockServletContext)1 RequestAttributes (org.springframework.web.context.request.RequestAttributes)1 ServletRequestAttributes (org.springframework.web.context.request.ServletRequestAttributes)1