SWF-941 Multiple Fragments not rendering

Restored rendering of multiple page fragments
This commit is contained in:
Scott Andrews
2008-11-10 15:12:14 +00:00
parent 0fcf816aaa
commit c972fc7c4c
3 changed files with 3 additions and 237 deletions

View File

@@ -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}.
*
* <p>
* This implementation will handle all dispatch requests by invoking {@link TilesRequestContext#include(String)} on the
* delegate request context.
* </p>
*
* @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);
}
}

View File

@@ -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]);