From seam-commits at lists.jboss.org Fri May 28 16:39:48 2010
Content-Type: multipart/mixed; boundary="===============0872151744401294213=="
MIME-Version: 1.0
From: seam-commits at lists.jboss.org
To: seam-commits at lists.jboss.org
Subject: [seam-commits] Seam SVN: r12895 - in modules/faces/trunk:
impl/src/main/java/org/jboss/seam/faces/context and 3 other directories.
Date: Fri, 28 May 2010 16:39:48 -0400
Message-ID: <201005282039.o4SKdmBn029901@svn01.web.mwc.hst.phx2.redhat.com>
--===============0872151744401294213==
Content-Type: text/plain; charset="utf-8"
MIME-Version: 1.0
Content-Transfer-Encoding: quoted-printable
Author: lincolnthree
Date: 2010-05-28 16:39:48 -0400 (Fri, 28 May 2010)
New Revision: 12895
Added:
modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/event/PreNavi=
gateEvent.java
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PreNav=
igateEventProducer.java
Modified:
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/Flas=
hScopedContext.java
modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/status/Messa=
gesAdapter.java
modules/faces/trunk/impl/src/main/resources/META-INF/faces-config.xml
Log:
Flash scope and MessagesAdapter are operational.
Added: modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/event/Pre=
NavigateEvent.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/event/PreNav=
igateEvent.java (rev 0)
+++ modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/event/PreNav=
igateEvent.java 2010-05-28 20:39:48 UTC (rev 12895)
@@ -0,0 +1,74 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.faces.event;
+
+import javax.faces.application.NavigationCase;
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+
+/**
+ * An event that is fired when JSF navigation is invoked via the
+ * {@link NavigationHandler}, but before any redirecting or non-redirecting
+ * navigation is completed, giving consumers of this event a chance to take
+ * action.
+ * =
+ * @author Lincoln Baxter, III=
+ * =
+ */
+public class PreNavigateEvent
+{
+
+ private final FacesContext context;
+ private final String fromAction;
+ private final String outcome;
+ private final NavigationCase navigationCase;
+
+ public PreNavigateEvent(final FacesContext context, final String fromAc=
tion, final String outcome, final NavigationCase navigationCase)
+ {
+ this.context =3D context;
+ this.fromAction =3D fromAction;
+ this.outcome =3D outcome;
+ this.navigationCase =3D navigationCase;
+ }
+
+ public FacesContext getContext()
+ {
+ return context;
+ }
+
+ public String getFromAction()
+ {
+ return fromAction;
+ }
+
+ public String getOutcome()
+ {
+ return outcome;
+ }
+
+ public NavigationCase getNavigationCase()
+ {
+ return navigationCase;
+ }
+
+}
Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/conte=
xt/FlashScopedContext.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/Fla=
shScopedContext.java 2010-05-28 16:35:02 UTC (rev 12894)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/context/Fla=
shScopedContext.java 2010-05-28 20:39:48 UTC (rev 12895)
@@ -95,13 +95,14 @@
String currentId =3D getCurrentId();
if (savedContextExists(currentId))
{
- FlashContext context =3D (FlashContext) getSessionMap().remove=
(getSessionKey(currentId));
+ FlashContext context =3D (FlashContext) getSessionMap().get(ge=
tSessionKey(currentId));
currentContext =3D context;
}
else
{
FlashContextImpl context =3D new FlashContextImpl();
context.setId(getNextFlashId());
+ getSessionMap().put(getSessionKey(context.getId()), context);
currentContext =3D context;
}
}
@@ -144,6 +145,8 @@
{
if (PhaseId.RENDER_RESPONSE.equals(event.getPhaseId()))
{
+ getSessionMap().remove(getSessionKey(currentContext.getId()));
+
Map, Object> componentInstanceMap =3D getComponentI=
nstanceMap();
Map, CreationalContext>> creationalContextMap =3D=
getCreationalContextMap();
=
Added: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/Pr=
eNavigateEventProducer.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PreNa=
vigateEventProducer.java (rev 0)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/event/PreNa=
vigateEventProducer.java 2010-05-28 20:39:48 UTC (rev 12895)
@@ -0,0 +1,69 @@
+/*
+ * JBoss, Home of Professional Open Source
+ * Copyright 2010, Red Hat, Inc., and individual contributors
+ * by the @authors tag. See the copyright.txt in the distribution for a
+ * full listing of individual contributors.
+ *
+ * This is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU Lesser General Public License as
+ * published by the Free Software Foundation; either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * This software is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with this software; if not, write to the Free
+ * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+ * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+ */
+
+package org.jboss.seam.faces.event;
+
+import java.util.Map;
+import java.util.Set;
+
+import javax.enterprise.inject.spi.BeanManager;
+import javax.faces.application.ConfigurableNavigationHandler;
+import javax.faces.application.NavigationCase;
+import javax.faces.context.FacesContext;
+
+import org.jboss.weld.extensions.beanManager.BeanManagerAccessor;
+
+/**
+ * @author Lincoln Baxter, III=
+ * =
+ */
+public class PreNavigateEventProducer extends ConfigurableNavigationHandler
+{
+ private final ConfigurableNavigationHandler parent;
+
+ public PreNavigateEventProducer(final ConfigurableNavigationHandler par=
ent)
+ {
+ this.parent =3D parent;
+ }
+
+ @Override
+ public NavigationCase getNavigationCase(final FacesContext context, fin=
al String fromAction, final String outcome)
+ {
+ return parent.getNavigationCase(context, fromAction, outcome);
+ }
+
+ @Override
+ public Map> getNavigationCases()
+ {
+ return parent.getNavigationCases();
+ }
+
+ @Override
+ public void handleNavigation(final FacesContext context, final String f=
romAction, final String outcome)
+ {
+ BeanManager manager =3D BeanManagerAccessor.getManager();
+ NavigationCase navigationCase =3D getNavigationCase(context, fromAct=
ion, outcome);
+ manager.fireEvent(new PreNavigateEvent(context, fromAction, outcome,=
navigationCase));
+ parent.handleNavigation(context, fromAction, outcome);
+ }
+
+}
Modified: modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/statu=
s/MessagesAdapter.java
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/status/Mess=
agesAdapter.java 2010-05-28 16:35:02 UTC (rev 12894)
+++ modules/faces/trunk/impl/src/main/java/org/jboss/seam/faces/status/Mess=
agesAdapter.java 2010-05-28 20:39:48 UTC (rev 12895)
@@ -23,6 +23,7 @@
package org.jboss.seam.faces.status;
=
import java.io.Serializable;
+import java.util.Set;
=
import javax.enterprise.event.Observes;
import javax.faces.application.FacesMessage;
@@ -30,6 +31,8 @@
import javax.faces.event.PhaseEvent;
import javax.inject.Inject;
=
+import org.jboss.seam.faces.context.FlashContext;
+import org.jboss.seam.faces.event.PreNavigateEvent;
import org.jboss.seam.faces.event.qualifier.Before;
import org.jboss.seam.faces.event.qualifier.RenderResponse;
import org.jboss.seam.international.status.Level;
@@ -47,13 +50,32 @@
{
private static final long serialVersionUID =3D -2908193057765795662L;
=
+ private static final String FLASH_MESSAGES_KEY =3D MessagesAdapter.clas=
s.getName() + ".FLASH_KEY";
+
@Inject
- private Messages messages;
+ Messages messages;
=
- // void flushBeforeNavigate(@Observes BeforeNavigateEvent event);
+ @Inject
+ FlashContext context;
=
+ void flushBeforeNavigate(@Observes final PreNavigateEvent event)
+ {
+ context.put(FLASH_MESSAGES_KEY, messages.getAll());
+ messages.clear();
+ }
+
+ @SuppressWarnings("unchecked")
void convert(@Observes @Before @RenderResponse final PhaseEvent event)
{
+ Set savedMessages =3D (Set) context.get(FLASH_MESS=
AGES_KEY);
+ if (savedMessages !=3D null)
+ {
+ for (Message m : savedMessages)
+ {
+ event.getFacesContext().addMessage(m.getTargets(), new FacesMe=
ssage(getSeverity(m.getLevel()), m.getText(), null));
+ }
+ }
+
for (Message m : messages.getAll())
{
event.getFacesContext().addMessage(m.getTargets(), new FacesMessa=
ge(getSeverity(m.getLevel()), m.getText(), null));
Modified: modules/faces/trunk/impl/src/main/resources/META-INF/faces-config=
.xml
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- modules/faces/trunk/impl/src/main/resources/META-INF/faces-config.xml 2=
010-05-28 16:35:02 UTC (rev 12894)
+++ modules/faces/trunk/impl/src/main/resources/META-INF/faces-config.xml 2=
010-05-28 20:39:48 UTC (rev 12895)
@@ -10,6 +10,9 @@
weld
+
+
+
=
@@ -21,6 +24,10 @@
=
+
+ org.jboss.seam.faces.event.PreNavigateEventProducer
+
+ =
org.jboss.seam.faces.event.DelegatingSyste=
mEventListener
javax.faces.event.ComponentSystemEvent
--===============0872151744401294213==--