Author: julien(a)jboss.com
Date: 2007-06-23 17:15:49 -0400 (Sat, 23 Jun 2007)
New Revision: 7515
Added:
trunk/faces/src/main/org/jboss/portal/faces/util/
trunk/faces/src/main/org/jboss/portal/faces/util/ActionEventDispatcher.java
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java
Log:
- update ui:portlet component to take in account the view state id part of the context
required by SunRI
- make page layout work with SunRI
Modified:
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java
===================================================================
---
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2007-06-22
21:13:55 UTC (rev 7514)
+++
trunk/core-admin/src/main/org/jboss/portal/core/admin/ui/common/PageManagerBean.java 2007-06-23
21:15:49 UTC (rev 7515)
@@ -329,7 +329,11 @@
Map actionParams = actionEvent.getParameterMap();
// Keep window name and region defined
- setWindowName(((String[])actionParams.get("windowName"))[0]);
+ String[] windowNames = ((String[])actionParams.get("windowName"));
+ if (windowNames != null && windowNames.length > 0)
+ {
+ setWindowName(windowNames[0]);
+ }
//
if (actionParams.get(CONTENT_ACTION_SELECT) != null)
Modified: trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml
===================================================================
--- trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml 2007-06-22
21:13:55 UTC (rev 7514)
+++ trunk/core-admin/src/resources/portal-admin-war/WEB-INF/jboss-portlet.xml 2007-06-23
21:15:49 UTC (rev 7515)
@@ -28,6 +28,9 @@
<portlet-app>
<portlet>
<portlet-name>AdminPortlet</portlet-name>
+ <ajax>
+ <partial-refresh>false</partial-refresh>
+ </ajax>
<transaction>
<trans-attribute>Required</trans-attribute>
</transaction>
@@ -37,6 +40,9 @@
</portlet>
<portlet>
<portlet-name>DashboardConfigPortlet</portlet-name>
+ <ajax>
+ <partial-refresh>false</partial-refresh>
+ </ajax>
<transaction>
<trans-attribute>Required</trans-attribute>
</transaction>
Modified: trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java
===================================================================
---
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java 2007-06-22
21:13:55 UTC (rev 7514)
+++
trunk/faces/src/main/org/jboss/portal/faces/component/portlet/UIPortlet.java 2007-06-23
21:15:49 UTC (rev 7515)
@@ -33,6 +33,8 @@
import org.jboss.portal.portlet.invocation.response.FragmentResponse;
import org.jboss.portal.Mode;
import org.jboss.portal.WindowState;
+import org.jboss.portal.faces.util.ActionEventDispatcher;
+import org.jboss.portal.common.util.Tools;
import javax.faces.component.UICommand;
import javax.faces.context.FacesContext;
@@ -43,11 +45,14 @@
import javax.faces.event.FacesEvent;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.PhaseId;
+import javax.faces.event.ActionListener;
+import javax.faces.event.ActionEvent;
import java.io.IOException;
import java.util.Map;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Set;
+import java.util.ArrayList;
/**
* @todo:
@@ -70,6 +75,9 @@
public class UIPortlet extends UICommand
{
+ /** . */
+ private final ActionEventDispatcher dispatcher = new ActionEventDispatcher(this);
+
/** The portlet invoker. */
private PortletInvoker portletInvoker;
@@ -359,32 +367,15 @@
{
if (event instanceof PortletEvent)
{
+ PortletEvent pevent = (PortletEvent)event;
+
+ //
FacesContext faces = getFacesContext();
//
- MethodBinding listener = getActionListener();
- if (listener != null)
- {
- try
- {
- listener.invoke(faces, new Object[] {event});
- }
- catch (EvaluationException e)
- {
- Throwable cause = e.getCause();
- if (cause != null && cause instanceof AbortProcessingException)
- {
- throw (AbortProcessingException)cause;
- }
- else
- {
- throw e;
- }
- }
- }
+ dispatcher.dispatch(faces, pevent);
//
- PortletEvent pevent = (PortletEvent)event;
pevent.execute(faces);
}
else
@@ -571,10 +562,10 @@
" }\n" +
// Temporary hack for Sun RI which encodes contextual state on
the page
-// " var viewStateId =
document.getElementById('javax.faces.ViewState')\n" +
-// " if (viewStateId != null) {\n" +
-// " this.params['javax.faces.ViewState'] =
viewStateId\n" +
-// " }\n" +
+ " var viewStateId =
document.getElementById('javax.faces.ViewState')\n" +
+ " if (viewStateId != null) {\n" +
+ " this.params['javax.faces.ViewState'] =
viewStateId.value\n" +
+ " }\n" +
"}\n" +
Added: trunk/faces/src/main/org/jboss/portal/faces/util/ActionEventDispatcher.java
===================================================================
--- trunk/faces/src/main/org/jboss/portal/faces/util/ActionEventDispatcher.java
(rev 0)
+++ trunk/faces/src/main/org/jboss/portal/faces/util/ActionEventDispatcher.java 2007-06-23
21:15:49 UTC (rev 7515)
@@ -0,0 +1,111 @@
+/******************************************************************************
+ * JBoss, a division of Red Hat *
+ * Copyright 2006, 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.faces.util;
+
+import org.jboss.portal.common.util.Tools;
+import org.apache.log4j.Logger;
+
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.component.UICommand;
+import javax.faces.el.MethodBinding;
+import javax.faces.el.EvaluationException;
+import javax.faces.context.FacesContext;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Iterator;
+
+/**
+ * The purpose of this class is to dispatch an event to the action listeners attached to
an instance of
+ * <code>UICommand</code> object. It will iterate the set of listeners
returned by the method
+ * <code>UICommand.getActionListeners()</code> (SunRI) and the listener
evaluated by the method binding returned
+ * by the method <code>getActionListener()</code> (MyFaces). So overally we
try to encapsulate the delivery of an
+ * action event in a portable way accross JSF implementations.
+ *
+ * @author <a href="mailto:julien@jboss.org">Julien Viet</a>
+ * @version $Revision: 1.1 $
+ */
+public class ActionEventDispatcher
+{
+
+ /** . */
+ private static final ActionListener[] EMPTY_LISTENERS = new ActionListener[0];
+
+ /** . */
+ private static final Logger log = Logger.getLogger(ActionEventDispatcher.class);
+
+ /** . */
+ private final UICommand command;
+
+ public ActionEventDispatcher(UICommand command)
+ {
+ this.command = command;
+ }
+
+ public void dispatch(final FacesContext faces, final ActionEvent event) throws
AbortProcessingException
+ {
+ //
+ ArrayList listeners = new ArrayList();
+
+ if (command.getActionListeners() != null)
+ {
+ listeners.addAll(Arrays.asList(command.getActionListeners()));
+ }
+
+ //
+ if (command.getActionListener() != null)
+ {
+ ActionListener listener = new ActionListener()
+ {
+ public void processAction(ActionEvent actionEvent) throws
AbortProcessingException
+ {
+ try
+ {
+ command.getActionListener().invoke(faces, new Object[] {event});
+ }
+ catch (EvaluationException e)
+ {
+ Throwable cause = e.getCause();
+ if (cause != null && cause instanceof
AbortProcessingException)
+ {
+ throw (AbortProcessingException)cause;
+ }
+ else
+ {
+ log.error("Was not able to evaluate the method binding",
e);
+ }
+ }
+ }
+ };
+ listeners.add(listener);
+ }
+
+ //
+ for (Iterator i = listeners.iterator(); i.hasNext();)
+ {
+ ActionListener listener = (ActionListener)i.next();
+ listener.processAction(event);
+ }
+ }
+}