diff --git a/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesRequestContext.java b/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesRequestContext.java deleted file mode 100644 index df49968a..00000000 --- a/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesRequestContext.java +++ /dev/null @@ -1,131 +0,0 @@ -/* - * Copyright 2004-2008 the original author or authors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package org.springframework.js.ajax.tiles2; - -import java.io.IOException; -import java.util.Locale; -import java.util.Map; - -import org.apache.tiles.context.TilesRequestContext; - -/** - * Tiles request context implementation that delegates to another {@link TilesRequestContext}. - * - *

- * This implementation will handle all dispatch requests by invoking {@link TilesRequestContext#include(String)} on the - * delegate request context. - *

- * - * @author Scott Andrews - */ -class AjaxTilesRequestContext implements TilesRequestContext { - - private final TilesRequestContext targetReqestContext; - - /** - * Create a TilesRequestContext for use by AjaxTilesView - * - * @param targetReqestContext the target {@link TilesRequestContext} - */ - public AjaxTilesRequestContext(TilesRequestContext targetReqestContext) { - this.targetReqestContext = targetReqestContext; - } - - /** - * Delegate call to {@link TilesRequestContext#include(String)} - */ - public void dispatch(String path) throws IOException { - targetReqestContext.include(path); - } - - /** - * {@inheritDoc} - */ - public Map getHeader() { - return targetReqestContext.getHeader(); - } - - /** - * {@inheritDoc} - */ - public Map getHeaderValues() { - return targetReqestContext.getHeaderValues(); - } - - /** - * {@inheritDoc} - */ - public Map getParam() { - return targetReqestContext.getParam(); - } - - /** - * {@inheritDoc} - */ - public Map getParamValues() { - return targetReqestContext.getParamValues(); - } - - /** - * {@inheritDoc} - */ - public Object getRequest() { - return targetReqestContext.getRequest(); - } - - /** - * {@inheritDoc} - */ - public Locale getRequestLocale() { - return targetReqestContext.getRequestLocale(); - } - - /** - * {@inheritDoc} - */ - public Map getRequestScope() { - return targetReqestContext.getRequestScope(); - } - - /** - * {@inheritDoc} - */ - public Object getResponse() { - return targetReqestContext.getResponse(); - } - - /** - * {@inheritDoc} - */ - public Map getSessionScope() { - return targetReqestContext.getSessionScope(); - } - - /** - * {@inheritDoc} - */ - public void include(String path) throws IOException { - targetReqestContext.include(path); - } - - /** - * {@inheritDoc} - */ - public boolean isUserInRole(String role) { - return targetReqestContext.isUserInRole(role); - } - -} diff --git a/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesView.java b/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesView.java index b9abd689..f0c4fb0c 100644 --- a/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesView.java +++ b/spring-js/src/main/java/org/springframework/js/ajax/tiles2/AjaxTilesView.java @@ -83,8 +83,8 @@ public class AjaxTilesView extends TilesView { exposeModelAsRequestAttributes(model, request); JstlUtils.exposeLocalizationContext(new RequestContext(request, servletContext)); - TilesRequestContext tilesRequestContext = new AjaxTilesRequestContext(container.getContextFactory() - .createRequestContext(container.getApplicationContext(), new Object[] { request, response })); + TilesRequestContext tilesRequestContext = container.getContextFactory().createRequestContext( + container.getApplicationContext(), new Object[] { request, response }); Definition compositeDefinition = container.getDefinitionsFactory().getDefinition(getUrl(), tilesRequestContext); Map flattenedAttributeMap = new HashMap(); @@ -93,6 +93,7 @@ public class AjaxTilesView extends TilesView { // initialize the session before rendering any fragments. Otherwise views that require the session which has // not otherwise been initialized will fail to render request.getSession(); + response.flushBuffer(); for (int i = 0; i < attrNames.length; i++) { Attribute attributeToRender = (Attribute) flattenedAttributeMap.get(attrNames[i]); diff --git a/spring-js/src/test/java/org/springframework/js/ajax/tiles2/AjaxTilesRequestContextTests.java b/spring-js/src/test/java/org/springframework/js/ajax/tiles2/AjaxTilesRequestContextTests.java deleted file mode 100644 index 59e8ca98..00000000 --- a/spring-js/src/test/java/org/springframework/js/ajax/tiles2/AjaxTilesRequestContextTests.java +++ /dev/null @@ -1,104 +0,0 @@ -package org.springframework.js.ajax.tiles2; - -import java.io.IOException; - -import junit.framework.TestCase; - -import org.apache.tiles.context.TilesRequestContext; -import org.easymock.EasyMock; - -public class AjaxTilesRequestContextTests extends TestCase { - - private TilesRequestContext targetContext; - private AjaxTilesRequestContext ajaxContext; - - protected void setUp() throws Exception { - targetContext = (TilesRequestContext) EasyMock.createMock(TilesRequestContext.class); - ajaxContext = new AjaxTilesRequestContext(targetContext); - } - - public void testGetHeader() { - EasyMock.expect(targetContext.getHeader()).andReturn(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.getHeader(); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testGetHeaderValues() { - EasyMock.expect(targetContext.getHeaderValues()).andReturn(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.getHeaderValues(); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testGetRequestScope() { - EasyMock.expect(targetContext.getRequestScope()).andReturn(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.getRequestScope(); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testGetSessionScope() { - EasyMock.expect(targetContext.getSessionScope()).andReturn(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.getSessionScope(); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testDispatch() throws IOException { - targetContext.include(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.dispatch(null); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testInclude() throws IOException { - targetContext.include(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.include(null); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testGetParam() { - EasyMock.expect(targetContext.getParam()).andReturn(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.getParam(); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testGetParamValues() { - EasyMock.expect(targetContext.getParamValues()).andReturn(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.getParamValues(); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testGetRequestLocale() { - EasyMock.expect(targetContext.getRequestLocale()).andReturn(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.getRequestLocale(); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testIsUserInRole() { - EasyMock.expect(Boolean.valueOf(targetContext.isUserInRole(null))).andReturn(Boolean.FALSE); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.isUserInRole(null); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testGetRequest() { - EasyMock.expect(targetContext.getRequest()).andReturn(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.getRequest(); - EasyMock.verify(new Object[] { targetContext }); - } - - public void testGetResponse() { - EasyMock.expect(targetContext.getResponse()).andReturn(null); - EasyMock.replay(new Object[] { targetContext }); - ajaxContext.getResponse(); - EasyMock.verify(new Object[] { targetContext }); - } - -}