org.apache.tiles.context.TilesRequestContext Java Examples
The following examples show how to use
org.apache.tiles.context.TilesRequestContext.
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 lams with GNU General Public License v2.0 | 6 votes |
@Override public boolean checkResource(final Locale locale) throws Exception { TilesContainer container = ServletUtil.getContainer(getServletContext()); if (!(container instanceof BasicTilesContainer)) { // Cannot check properly - let's assume it's there. return true; } BasicTilesContainer basicContainer = (BasicTilesContainer) container; TilesApplicationContext appContext = new ServletTilesApplicationContext(getServletContext()); TilesRequestContext requestContext = new ServletTilesRequestContext(appContext, null, null) { @Override public Locale getRequestLocale() { return locale; } }; return (basicContainer.getDefinitionsFactory().getDefinition(getUrl(), requestContext) != null); }
Example #2
Source File: TilesView.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Override public boolean checkResource(final Locale locale) throws Exception { TilesContainer container = ServletUtil.getContainer(getServletContext()); if (!(container instanceof BasicTilesContainer)) { // Cannot check properly - let's assume it's there. return true; } BasicTilesContainer basicContainer = (BasicTilesContainer) container; TilesApplicationContext appContext = new ServletTilesApplicationContext(getServletContext()); TilesRequestContext requestContext = new ServletTilesRequestContext(appContext, null, null) { @Override public Locale getRequestLocale() { return locale; } }; return (basicContainer.getDefinitionsFactory().getDefinition(getUrl(), requestContext) != null); }
Example #3
Source File: TilesConfigurerTests.java From spring4-understanding with Apache License 2.0 | 6 votes |
@Test @SuppressWarnings("deprecation") public void simpleBootstrap() { MockServletContext sc = new MockServletContext(); TilesConfigurer tc = new TilesConfigurer(); tc.setDefinitions("/org/springframework/web/servlet/view/tiles2/tiles-definitions.xml"); tc.setCheckRefresh(true); tc.setServletContext(sc); tc.afterPropertiesSet(); BasicTilesContainer container = (BasicTilesContainer) ServletUtil.getContainer(sc); TilesRequestContext requestContext = new ServletTilesRequestContext( container.getApplicationContext(), new MockHttpServletRequest(), new MockHttpServletResponse()); assertNotNull(container.getDefinitionsFactory().getDefinition("test", requestContext)); tc.destroy(); }
Example #4
Source File: SpringLocaleResolver.java From lams with GNU General Public License v2.0 | 5 votes |
@Override public Locale resolveLocale(TilesRequestContext context) { if (context instanceof JspTilesRequestContext) { PageContext pc = ((JspTilesRequestContext) context).getPageContext(); return RequestContextUtils.getLocale((HttpServletRequest) pc.getRequest()); } else if (context instanceof ServletTilesRequestContext) { HttpServletRequest request = ((ServletTilesRequestContext) context).getRequest(); if (request != null) { return RequestContextUtils.getLocale(request); } } return super.resolveLocale(context); }
Example #5
Source File: SpringLocaleResolver.java From spring4-understanding with Apache License 2.0 | 5 votes |
@Override public Locale resolveLocale(TilesRequestContext context) { if (context instanceof JspTilesRequestContext) { PageContext pc = ((JspTilesRequestContext) context).getPageContext(); return RequestContextUtils.getLocale((HttpServletRequest) pc.getRequest()); } else if (context instanceof ServletTilesRequestContext) { HttpServletRequest request = ((ServletTilesRequestContext) context).getRequest(); if (request != null) { return RequestContextUtils.getLocale(request); } } return super.resolveLocale(context); }
Example #6
Source File: UserViewPreparer.java From website with GNU Affero General Public License v3.0 | 5 votes |
public void execute(TilesRequestContext tilesContext, AttributeContext attributeContext) throws PreparerException { if (AuthenticationService.currentActingUser() != null) { User user = AuthenticationService.currentAuthenticatedUser(); User actingUser = AuthenticationService.currentActingUser(); attributeContext.putAttribute("actingUser", new Attribute(actingUser)); attributeContext.putAttribute("user", new Attribute(user)); } }