org.apache.tiles.request.servlet.ServletRequest Java Examples

The following examples show how to use org.apache.tiles.request.servlet.ServletRequest. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: TilesView.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@Override
public boolean checkResource(final Locale locale) throws Exception {
	Assert.state(this.renderer != null, "No Renderer set");

	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);
}
 
Example #2
Source File: TilesConfigurerTests.java    From spring-analysis-note with MIT License 6 votes vote down vote up
@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();
}
 
Example #3
Source File: TilesView.java    From java-technology-stack with MIT License 6 votes vote down vote up
@Override
public boolean checkResource(final Locale locale) throws Exception {
	Assert.state(this.renderer != null, "No Renderer set");

	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);
}
 
Example #4
Source File: TilesConfigurerTests.java    From java-technology-stack with MIT License 6 votes vote down vote up
@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();
}
 
Example #5
Source File: TilesConfigurerTests.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@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();
}
 
Example #6
Source File: TilesView.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Create a Tiles {@link Request}.
 * <p>This implementation creates a {@link ServletRequest}.
 * @param request the current request
 * @param response the current response
 * @return the Tiles request
 */
protected Request createTilesRequest(final HttpServletRequest request, HttpServletResponse response) {
	return new ServletRequest(this.applicationContext, request, response) {
		@Override
		public Locale getRequestLocale() {
			return RequestContextUtils.getLocale(request);
		}
	};
}
 
Example #7
Source File: TilesView.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Create a Tiles {@link Request}.
 * <p>This implementation creates a {@link ServletRequest}.
 * @param request the current request
 * @param response the current response
 * @return the Tiles request
 */
protected Request createTilesRequest(final HttpServletRequest request, HttpServletResponse response) {
	return new ServletRequest(this.applicationContext, request, response) {
		@Override
		public Locale getRequestLocale() {
			return RequestContextUtils.getLocale(request);
		}
	};
}
 
Example #8
Source File: TilesView.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@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);
}
 
Example #9
Source File: TilesView.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Create a Tiles {@link Request}.
 * <p>This implementation creates a {@link ServletRequest}.
 * @param request the current request
 * @param response the current response
 * @return the Tiles request
 */
protected Request createTilesRequest(final HttpServletRequest request, HttpServletResponse response) {
	return new ServletRequest(this.applicationContext, request, response) {
		@Override
		public Locale getRequestLocale() {
			return RequestContextUtils.getLocale(request);
		}
	};
}
 
Example #10
Source File: TilesView.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@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);
}
 
Example #11
Source File: TilesView.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Create a Tiles {@link Request}.
 * <p>This implementation creates a {@link ServletRequest}.
 * @param request the current request
 * @param response the current response
 * @return the Tiles request
 */
protected Request createTilesRequest(final HttpServletRequest request, HttpServletResponse response) {
	return new ServletRequest(this.applicationContext, request, response) {
		@Override
		public Locale getRequestLocale() {
			return RequestContextUtils.getLocale(request);
		}
	};
}