Author: chris.laprun(a)jboss.com
Date: 2009-01-22 18:54:47 -0500 (Thu, 22 Jan 2009)
New Revision: 12612
Added:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerNavigationHandler.java
Removed:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerListener.java
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerBeanTestCase.java
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml
Log:
- JBPORTAL-2274: Different approach using a NavigationHandler instead of PhaseListener
that should work now...
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerBeanTestCase.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerBeanTestCase.java 2009-01-22
17:46:05 UTC (rev 12611)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/test/wsrp/other/ConsumerBeanTestCase.java 2009-01-22
23:54:47 UTC (rev 12612)
@@ -1,6 +1,6 @@
/******************************************************************************
* JBoss, a division of Red Hat *
- * Copyright 2007, Red Hat Middleware, LLC, and individual *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
* contributors as indicated by the @authors tag. See the *
* copyright.txt in the distribution for a full listing of *
* individual contributors. *
@@ -68,7 +68,7 @@
public void testSetCache()
{
- bean.setCache(new Integer(300));
+ bean.setCache(300);
assertEquals(300, bean.getCache().intValue());
assertTrue(bean.isModified());
}
Deleted:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerListener.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerListener.java 2009-01-22
17:46:05 UTC (rev 12611)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerListener.java 2009-01-22
23:54:47 UTC (rev 12612)
@@ -1,69 +0,0 @@
-/******************************************************************************
- * JBoss, a division of Red Hat *
- * Copyright 2009, Red Hat Middleware, LLC, and individual *
- * contributors as indicated 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.portal.wsrp.admin.ui;
-
-import org.jboss.portal.faces.gui.JSFBeanContext;
-
-import javax.faces.application.NavigationHandler;
-import javax.faces.context.FacesContext;
-import javax.faces.event.PhaseEvent;
-import javax.faces.event.PhaseId;
-import javax.faces.event.PhaseListener;
-
-/**
- * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
- * @version $Revision$
- */
-public class RedirectOnNoConsumerListener implements PhaseListener
-{
- public void afterPhase(PhaseEvent phaseEvent)
- {
- FacesContext facesContext = phaseEvent.getFacesContext();
-
- // check if we have a currently selected consumer in the request...
- String currentConsumer =
JSFBeanContext.getParameter(ConsumerManagerBean.REQUESTED_CONSUMER_ID, facesContext);
-
- // if not, check the session...
- if (currentConsumer == null)
- {
- currentConsumer =
(String)JSFBeanContext.getSessionMap(facesContext).get(ConsumerManagerBean.SESSION_CONSUMER_ID);
-
- // if we still don't have consumer id, redirect to consumer list view
- if (currentConsumer == null)
- {
- NavigationHandler navigationHandler =
facesContext.getApplication().getNavigationHandler();
- navigationHandler.handleNavigation(facesContext, null,
"consumers");
- }
- }
- }
-
- public void beforePhase(PhaseEvent phaseEvent)
- {
- }
-
- public PhaseId getPhaseId()
- {
- return PhaseId.RESTORE_VIEW;
- }
-}
Added:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerNavigationHandler.java
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerNavigationHandler.java
(rev 0)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/main/org/jboss/portal/wsrp/admin/ui/RedirectOnNoConsumerNavigationHandler.java 2009-01-22
23:54:47 UTC (rev 12612)
@@ -0,0 +1,69 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2009, Red Hat Middleware, LLC, and individual *
+ * contributors as indicated 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.portal.wsrp.admin.ui;
+
+import org.jboss.portal.faces.gui.JSFBeanContext;
+
+import javax.faces.application.NavigationHandler;
+import javax.faces.context.FacesContext;
+
+/**
+ * @author <a href="mailto:chris.laprun@jboss.com">Chris
Laprun</a>
+ * @version $Revision$
+ */
+public class RedirectOnNoConsumerNavigationHandler extends NavigationHandler
+{
+ private NavigationHandler base;
+ private static final String CONFIGURE_CONSUMER = "configureConsumer";
+ private static final String CONSUMERS = "consumers";
+
+ public RedirectOnNoConsumerNavigationHandler(NavigationHandler base)
+ {
+ this.base = base;
+ }
+
+ public void handleNavigation(FacesContext facesContext, String fromAction, String
outcome)
+ {
+ // only check for need to redirect when we're asking for consumer details
+ if (CONFIGURE_CONSUMER.equals(outcome))
+ {
+ // check if we have a currently selected consumer in the request...
+ String currentConsumer =
JSFBeanContext.getParameter(ConsumerManagerBean.REQUESTED_CONSUMER_ID, facesContext);
+
+ // if not, check the session...
+ if (currentConsumer == null)
+ {
+ currentConsumer =
(String)JSFBeanContext.getSessionMap(facesContext).get(ConsumerManagerBean.SESSION_CONSUMER_ID);
+
+ // if we still don't have consumer id, redirect to consumer list view
+ if (currentConsumer == null)
+ {
+ outcome = CONSUMERS;
+ }
+ }
+ }
+
+ base.handleNavigation(facesContext, fromAction, outcome);
+ }
+}
Modified:
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml
===================================================================
---
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml 2009-01-22
17:46:05 UTC (rev 12611)
+++
branches/JBoss_Portal_Branch_2_7/core-wsrp/src/resources/portal-wsrp-admin-war/WEB-INF/faces-config.xml 2009-01-22
23:54:47 UTC (rev 12612)
@@ -33,6 +33,7 @@
<view-handler>
org.jboss.portletbridge.application.PortletViewHandler
</view-handler>
+
<navigation-handler>org.jboss.portal.wsrp.admin.ui.RedirectOnNoConsumerNavigationHandler</navigation-handler>
<state-manager>org.jboss.portletbridge.application.PortletStateManager</state-manager>
<locale-config>
<default-locale>en</default-locale>
@@ -41,10 +42,6 @@
</locale-config>
</application>
- <lifecycle>
-
<phase-listener>org.jboss.portal.wsrp.admin.ui.RedirectOnNoConsumerListener</phase-listener>
- </lifecycle>
-
<converter>
<converter-for-class>org.jboss.portal.wsrp.registration.LocalizedString</converter-for-class>
<converter-class>org.jboss.portal.wsrp.admin.ui.LocalizedStringConverter</converter-class>
@@ -80,6 +77,11 @@
<managed-bean-class>org.jboss.portal.wsrp.admin.ui.ConsumerBean</managed-bean-class>
<managed-bean-scope>session</managed-bean-scope>
<managed-property>
+ <property-name>beanContext</property-name>
+
<property-class>org.jboss.portal.faces.gui.BeanContext</property-class>
+ <value>#{beanContext}</value>
+ </managed-property>
+ <managed-property>
<property-name>registry</property-name>
<property-class>org.jboss.portal.wsrp.consumer.ConsumerRegistry</property-class>
<value>#{applicationScope.ConsumerRegistry}</value>
@@ -92,11 +94,6 @@
<property-name>manager</property-name>
<value>#{consumersMgr}</value>
</managed-property>
- <managed-property>
- <property-name>beanContext</property-name>
-
<property-class>org.jboss.portal.faces.gui.BeanContext</property-class>
- <value>#{beanContext}</value>
- </managed-property>
</managed-bean>
<managed-bean>
<managed-bean-name>producer</managed-bean-name>