[seam-commits] Seam SVN: r10700 - in modules/trunk/faces/src/main: resources/META-INF and 1 other directory.
seam-commits at lists.jboss.org
seam-commits at lists.jboss.org
Wed Apr 29 01:58:25 EDT 2009
Author: dan.j.allen
Date: 2009-04-29 01:58:25 -0400 (Wed, 29 Apr 2009)
New Revision: 10700
Added:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java
Removed:
modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/StatusMessagesTranslator.java
Modified:
modules/trunk/faces/src/main/resources/META-INF/faces-config.xml
Log:
go back to using XML to configure preRenderViewEvent listener
rename component
support both absolute and relative client ids for messages
Deleted: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/StatusMessagesTranslator.java
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/StatusMessagesTranslator.java 2009-04-29 05:57:37 UTC (rev 10699)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/StatusMessagesTranslator.java 2009-04-29 05:58:25 UTC (rev 10700)
@@ -1,42 +0,0 @@
-package org.jboss.seam.faces.lifecycle;
-
-import java.beans.Introspector;
-import javax.faces.component.UIViewRoot;
-import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
-import javax.faces.event.ComponentSystemEvent;
-import javax.faces.event.ComponentSystemEventListener;
-import javax.faces.event.ListenerFor;
-import javax.faces.event.PreRenderViewEvent;
-import org.jboss.seam.faces.FacesMessages;
-import org.jboss.seam.international.StatusMessages;
-
-/**
- * A {@link ComponentSystemEventListener} that observes the PreRenderViewEvent and
- * transposes Seam StatusMessage objects into FacesMessage objects
- * and stores them in the FacesContext.
- *
- * @author Dan Allen
- */
- at ListenerFor(systemEventClass = PreRenderViewEvent.class, sourceClass = UIViewRoot.class)
-public class StatusMessagesTranslator implements ComponentSystemEventListener {
-
- public void processEvent(ComponentSystemEvent preRenderViewEvent) throws AbortProcessingException
- {
- FacesContext context = FacesContext.getCurrentInstance();
- FacesMessages facesMessages = (FacesMessages) context.getApplication().getExpressionFactory()
- .createValueExpression(getBeanExpression(StatusMessages.class), FacesMessages.class).getValue(context.getELContext());
- facesMessages.beforeRenderView();
- }
-
- private String getBeanName(Class beanClass)
- {
- return beanClass.getPackage() + "." + Introspector.decapitalize(beanClass.getSimpleName());
- }
-
- private String getBeanExpression(Class beanClass)
- {
- return "#{" + getBeanName(beanClass) + "}";
- }
-
-}
Copied: modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java (from rev 10677, modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/StatusMessagesTranslator.java)
===================================================================
--- modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java (rev 0)
+++ modules/trunk/faces/src/main/java/org/jboss/seam/faces/lifecycle/TransferStatusMessagesListener.java 2009-04-29 05:58:25 UTC (rev 10700)
@@ -0,0 +1,44 @@
+package org.jboss.seam.faces.lifecycle;
+
+import java.beans.Introspector;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ComponentSystemEventListener;
+import javax.faces.event.SystemEvent;
+import javax.faces.event.SystemEventListener;
+import org.jboss.seam.el.Expressions;
+import org.jboss.seam.faces.FacesExpressions;
+import org.jboss.seam.international.StatusMessages;
+
+/**
+ * A {@link SystemEventListener} that observes the PreRenderViewEvent and
+ * transposes Seam StatusMessage objects into FacesMessage objects
+ * and transfers them to the FacesContext.
+ *
+ * @author Dan Allen
+ */
+//@ListenerFor(systemEventClass = PreRenderViewEvent.class, sourceClass = UIViewRoot.class)
+public class TransferStatusMessagesListener implements SystemEventListener
+{
+ public void processEvent(SystemEvent preRenderViewEvent)
+ {
+ Expressions expressions = new FacesExpressions();
+ // FIXME this is kind of ugly...reminds me of the bad old days of JSF managed beans
+ StatusMessages statusMessages = (StatusMessages) expressions.createValueExpression(getBeanExpression(StatusMessages.class)).getValue();
+ statusMessages.onBeforeRender();
+ }
+
+ public boolean isListenerForSource(Object source)
+ {
+ return true;
+ }
+
+ private String getBeanName(Class beanClass)
+ {
+ return beanClass.getPackage().getName() + "." + Introspector.decapitalize(beanClass.getSimpleName());
+ }
+
+ private String getBeanExpression(Class beanClass)
+ {
+ return "#{" + getBeanName(beanClass) + "}";
+ }
+}
Modified: modules/trunk/faces/src/main/resources/META-INF/faces-config.xml
===================================================================
--- modules/trunk/faces/src/main/resources/META-INF/faces-config.xml 2009-04-29 05:57:37 UTC (rev 10699)
+++ modules/trunk/faces/src/main/resources/META-INF/faces-config.xml 2009-04-29 05:58:25 UTC (rev 10700)
@@ -16,6 +16,10 @@
<application>
<el-resolver>org.jboss.seam.el.SeamELResolver</el-resolver>
<el-resolver>org.jboss.seam.faces.el.SeamFacesELResolver</el-resolver>
+ <system-event-listener>
+ <system-event-class>javax.faces.event.PreRenderViewEvent</system-event-class>
+ <system-event-listener-class>org.jboss.seam.faces.lifecycle.TransferStatusMessagesListener</system-event-listener-class>
+ </system-event-listener>
</application>
</faces-config>
More information about the seam-commits
mailing list