From 1d979b7b2df3a666b117a69b2356ff57ac40c424 Mon Sep 17 00:00:00 2001 From: Jeremy Grelle Date: Wed, 14 Jan 2009 22:21:01 +0000 Subject: [PATCH] SWF-856 - When using JSF getMaximumSeverity on the FlowFacesContext returns null even if a message has been added --- .../faces/webflow/FlowFacesContext.java | 28 ++++++++++--------- .../faces/webflow/FlowFacesContextTests.java | 6 ++++ 2 files changed, 21 insertions(+), 13 deletions(-) diff --git a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java index f83ceb73..48ec0f87 100644 --- a/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java +++ b/spring-faces/src/main/java/org/springframework/faces/webflow/FlowFacesContext.java @@ -93,6 +93,21 @@ public class FlowFacesContext extends FacesContext { return messageDelegate.getClientIdsWithMessages(); } + public ELContext getELContext() { + Method delegateMethod = ClassUtils.getMethodIfAvailable(delegate.getClass(), "getELContext", null); + if (delegateMethod != null) { + try { + ELContext context = (ELContext) delegateMethod.invoke(delegate, null); + context.putContext(FacesContext.class, this); + return context; + } catch (Exception e) { + return null; + } + } else { + return null; + } + } + /** * Return the maximum severity level recorded on any FacesMessages that has been queued, whether or not they are * associated with any specific UIComponent. If no such messages have been queued, return null. @@ -143,19 +158,6 @@ public class FlowFacesContext extends FacesContext { return delegate.getApplication(); } - public ELContext getELContext() { - Method delegateMethod = ClassUtils.getMethodIfAvailable(delegate.getClass(), "getELContext", null); - if (delegateMethod != null) { - try { - return (ELContext) delegateMethod.invoke(delegate, null); - } catch (Exception e) { - return null; - } - } else { - return null; - } - } - public ExternalContext getExternalContext() { return new FlowExternalContext(delegate.getExternalContext()); } diff --git a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowFacesContextTests.java b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowFacesContextTests.java index 27f0c7bb..78fffc6b 100644 --- a/spring-faces/src/test/java/org/springframework/faces/webflow/FlowFacesContextTests.java +++ b/spring-faces/src/test/java/org/springframework/faces/webflow/FlowFacesContextTests.java @@ -176,6 +176,12 @@ public class FlowFacesContextTests extends TestCase { assertEquals(FacesMessage.SEVERITY_FATAL, facesContext.getMaximumSeverity()); } + public final void testGetELContext() { + + assertNotNull(facesContext.getELContext()); + assertSame(facesContext, facesContext.getELContext().getContext(FacesContext.class)); + } + private void setupMessageContext() { prepopulatedMessageContext = new DefaultMessageContext(); prepopulatedMessageContext.addMessage(new MessageBuilder().source("null_summary").defaultText("foo").info()