Proper handling of AjaxViewRoot in JsfView.saveState
This commit is contained in:
@@ -46,7 +46,7 @@ public abstract class DelegatingViewRoot extends UIViewRoot {
|
||||
this.original = original;
|
||||
}
|
||||
|
||||
protected UIViewRoot getOriginalViewRoot() {
|
||||
public UIViewRoot getOriginalViewRoot() {
|
||||
return original;
|
||||
}
|
||||
|
||||
|
||||
@@ -24,6 +24,7 @@ import javax.faces.lifecycle.Lifecycle;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.springframework.faces.ui.AjaxViewRoot;
|
||||
import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.View;
|
||||
@@ -120,7 +121,11 @@ public class JsfView implements View {
|
||||
*/
|
||||
public void saveState() {
|
||||
FacesContext facesContext = FlowFacesContext.newInstance(requestContext, facesLifecycle);
|
||||
facesContext.setViewRoot(viewRoot);
|
||||
if (viewRoot instanceof AjaxViewRoot) {
|
||||
facesContext.setViewRoot(((AjaxViewRoot) viewRoot).getOriginalViewRoot());
|
||||
} else {
|
||||
facesContext.setViewRoot(viewRoot);
|
||||
}
|
||||
try {
|
||||
facesContext.getApplication().getStateManager().saveView(facesContext);
|
||||
} finally {
|
||||
|
||||
@@ -65,7 +65,7 @@ public class JsfViewTests extends TestCase {
|
||||
|
||||
jsfMock.setUp();
|
||||
jsfMock.facesContext().getApplication().setViewHandler(new MockViewHandler());
|
||||
jsfMock.application().setStateManager(new TestStateManager());
|
||||
jsfMock.facesContext().getApplication().setStateManager(new TestStateManager());
|
||||
jsfMock.facesContext().setResponseWriter(new MockResponseWriter(output, null, null));
|
||||
|
||||
UIViewRoot viewToRender = new UIViewRoot();
|
||||
@@ -96,6 +96,17 @@ public class JsfViewTests extends TestCase {
|
||||
jsfMock.tearDown();
|
||||
}
|
||||
|
||||
public final void testSaveState() {
|
||||
EasyMock.replay(new Object[] { context, flowExecutionContext, flowMap, flashScope });
|
||||
view.saveState();
|
||||
}
|
||||
|
||||
public final void testSaveState_AjaxViewRoot() {
|
||||
EasyMock.replay(new Object[] { context, flowExecutionContext, flowMap, flashScope });
|
||||
view.setViewRoot(new AjaxViewRoot(view.getViewRoot()));
|
||||
view.saveState();
|
||||
}
|
||||
|
||||
public final void testRender() throws IOException {
|
||||
|
||||
EasyMock.expect(flashScope.put(EasyMock.matches(FlowFacesContext.RENDER_RESPONSE_KEY), EasyMock.anyObject()))
|
||||
|
||||
Reference in New Issue
Block a user