You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by bo...@apache.org on 2009/12/07 17:50:08 UTC

svn commit: r887996 - in /myfaces/tobago/trunk: core/src/main/java/org/apache/myfaces/tobago/event/ core/src/main/java/org/apache/myfaces/tobago/taglib/component/ core/src/main/java/org/apache/myfaces/tobago/util/ theme/standard/src/main/java/org/apach...

Author: bommel
Date: Mon Dec  7 16:50:02 2009
New Revision: 887996

URL: http://svn.apache.org/viewvc?rev=887996&view=rev
Log:
(TOBAGO-753) valueExpression support for 1.5

(TOBAGO-834) PopupActionListener has wrong popup reference if Component tree is rebuild before render view

Added:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java   (with props)
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java   (with props)
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java   (with props)
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java   (with props)
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComponentFindUtils.java   (with props)
Modified:
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupActionListener.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupReferenceTag.java
    myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
    myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/compat/FacesUtils.java
    myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/compat/FacesUtils.java

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupActionListener.java?rev=887996&r1=887995&r2=887996&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupActionListener.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupActionListener.java Mon Dec  7 16:50:02 2009
@@ -22,17 +22,15 @@
 import org.apache.myfaces.tobago.component.AbstractUIPopup;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 
+import javax.faces.component.StateHolder;
 import javax.faces.context.FacesContext;
-import javax.faces.event.AbortProcessingException;
 import javax.faces.event.ActionEvent;
-import javax.faces.event.ActionListener;
-import java.io.Serializable;
 
 /*
  * Date: Dec 23, 2006
  * Time: 10:59:53 AM
  */
-public class PopupActionListener implements ActionListener, Serializable {
+public class PopupActionListener extends AbstractPopupActionListener implements StateHolder {
 
   private static final Log LOG = LogFactory.getLog(PopupActionListener.class);
 
@@ -48,25 +46,34 @@
     }
   }
 
-  public PopupActionListener(AbstractUIPopup popup) {
-    this.popupId = ":" + popup.getClientId(FacesContext.getCurrentInstance());
-    if (LOG.isDebugEnabled()) {
-      LOG.debug("Add ActionListener: " + popupId);
+  @Override
+  protected AbstractUIPopup getPopup(ActionEvent actionEvent) {
+    FacesContext facesContext = FacesContext.getCurrentInstance();
+    AbstractUIPopup popup = (AbstractUIPopup) ComponentUtils.findComponent(actionEvent.getComponent(), popupId);
+    if (popup == null) {
+      LOG.error("Found no popup for \""
+          + popupId + "\"! Search base componentId : "
+          + actionEvent.getComponent().getClientId(facesContext));
     }
+    return popup;
   }
 
-  public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
-    AbstractUIPopup popup = (AbstractUIPopup) ComponentUtils.findComponent(actionEvent.getComponent(), popupId);
-    if (popup != null) {
-      if (LOG.isDebugEnabled()) {
-        LOG.debug("activated "
-            + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
-      }
-      popup.setActivated(true);
-    } else {
-      LOG.error("Found no popup for " + popupId + " search base component "
-              + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
-    }
+  public boolean isTransient() {
+    return false;
   }
 
+  public void restoreState(FacesContext context, Object state) {
+    Object values[] = (Object[])state;
+    popupId = (String) values[0];
+  }
+
+  public Object saveState(FacesContext context) {
+    Object values[] = new Object[1];
+    values[0] = popupId;
+    return values;
+  }
+
+  public void setTransient(boolean newTransientValue) {
+    // ignore
+  }
 }

Added: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java?rev=887996&view=auto
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java (added)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java Mon Dec  7 16:50:02 2009
@@ -0,0 +1,33 @@
+/*
+ * Created by IntelliJ IDEA.
+ * User: bommel
+ * Date: Dec 4, 2009
+ * Time: 5:16:38 PM
+ */
+package org.apache.myfaces.tobago.event;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.component.AbstractUIPopup;
+import org.apache.myfaces.tobago.component.Facets;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+public class PopupFacetActionListener extends AbstractPopupActionListener {
+
+  private static final Log LOG = LogFactory.getLog(PopupActionListener.class);
+
+  @Override
+  protected UIComponent getPopup(ActionEvent actionEvent) {
+    UIComponent component = actionEvent.getComponent().getFacet(Facets.POPUP);
+    if (component instanceof AbstractUIPopup) {
+      return component;
+    } else {
+      LOG.error("Found no popup facet in component "
+          + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
+    }
+    return null;
+  }
+}
\ No newline at end of file

Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupReferenceTag.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupReferenceTag.java?rev=887996&r1=887995&r2=887996&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupReferenceTag.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/taglib/component/PopupReferenceTag.java Mon Dec  7 16:50:02 2009
@@ -21,6 +21,7 @@
 import org.apache.myfaces.tobago.apt.annotation.Tag;
 import org.apache.myfaces.tobago.apt.annotation.TagAttribute;
 import org.apache.myfaces.tobago.apt.annotation.TagGeneration;
+import org.apache.myfaces.tobago.compat.FacesUtils;
 import org.apache.myfaces.tobago.event.PopupActionListener;
 
 import javax.faces.component.ActionSource;
@@ -50,6 +51,10 @@
   @TagAttribute(required = true, name ="for")
   public abstract String getForValue();
 
+  public abstract boolean isForLiteral();
+
+  public abstract Object getForAsBindingOrExpression();
+
   public int doStartTag() throws JspException {
 
     // Locate our parent UIComponentTag
@@ -74,7 +79,11 @@
       throw new JspException("Component " + component.getClass().getName() + " is not instanceof ActionSource");
     }
     ActionSource actionSource = (ActionSource) component;
-    actionSource.addActionListener(new PopupActionListener(getForValue()));
+    if (isForLiteral()) {
+      actionSource.addActionListener(new PopupActionListener(getForValue()));
+    } else {
+      FacesUtils.addBindingOrExpressionPopupActionListener(actionSource, getForAsBindingOrExpression());
+    }
     return (SKIP_BODY);
   }
 

Modified: myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=887996&r1=887995&r2=887996&view=diff
==============================================================================
--- myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/trunk/core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Mon Dec  7 16:50:02 2009
@@ -812,32 +812,7 @@
    */
 
   public static UIComponent findComponent(UIComponent from, String relativeId) {
-    int idLength = relativeId.length();
-    // Figure out how many colons
-    int colonCount = 0;
-    while (colonCount < idLength) {
-      if (relativeId.charAt(colonCount) != NamingContainer.SEPARATOR_CHAR) {
-        break;
-      }
-      colonCount++;
-    }
-
-    // colonCount == 0: fully relative
-    // colonCount == 1: absolute (still normal findComponent syntax)
-    // colonCount > 1: for each extra colon after 1, go up a naming container
-    // (to the view root, if naming containers run out)
-    if (colonCount > 1) {
-      relativeId = relativeId.substring(colonCount);
-      for (int j = 1; j < colonCount; j++) {
-        while (from.getParent() != null) {
-          from = from.getParent();
-          if (from instanceof NamingContainer) {
-            break;
-          }
-        }
-      }
-    }
-    return from.findComponent(relativeId);
+    return ComponentFindUtils.findComponent(from, relativeId);
   }
 
   public static String[] splitList(String renderers) {

Modified: myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java?rev=887996&r1=887995&r2=887996&view=diff
==============================================================================
--- myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java (original)
+++ myfaces/tobago/trunk/theme/standard/src/main/java/org/apache/myfaces/tobago/renderkit/html/util/CommandRendererHelper.java Mon Dec  7 16:50:02 2009
@@ -25,7 +25,7 @@
 import org.apache.myfaces.tobago.component.UIPopup;
 import org.apache.myfaces.tobago.context.ClientProperties;
 import org.apache.myfaces.tobago.context.ResourceManagerUtil;
-import org.apache.myfaces.tobago.event.PopupActionListener;
+import org.apache.myfaces.tobago.event.PopupFacetActionListener;
 import org.apache.myfaces.tobago.util.ComponentUtils;
 
 import javax.faces.application.Application;
@@ -72,7 +72,7 @@
       UIPopup popup = (UIPopup) command.getFacet(Facets.POPUP);
       if (popup != null) {
         if (!ComponentUtils.containsPopupActionListener(command)) {
-          command.addActionListener(new PopupActionListener(popup));
+          command.addActionListener(new PopupFacetActionListener());
         }
       }
 
@@ -135,7 +135,6 @@
         }
 
       }
-
       onclick = appendConfirmationScript(onclick, command);
     }
   }

Modified: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/compat/FacesUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/compat/FacesUtils.java?rev=887996&r1=887995&r2=887996&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/compat/FacesUtils.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/compat/FacesUtils.java Mon Dec  7 16:50:02 2009
@@ -20,12 +20,15 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.event.TabChangeSource;
+import org.apache.myfaces.tobago.event.ValueBindingPopupActionListener;
 import org.apache.myfaces.tobago.event.ValueBindingTabChangeListener;
 import org.apache.myfaces.tobago.util.ValueBindingComparator;
 
+import javax.faces.component.ActionSource;
 import javax.faces.component.ContextCallback;
 import javax.faces.component.EditableValueHolder;
 import javax.faces.component.NamingContainer;
+import javax.faces.component.UICommand;
 import javax.faces.component.UIComponent;
 import javax.faces.component.ValueHolder;
 import javax.faces.context.FacesContext;
@@ -180,4 +183,8 @@
     ValueBinding valueBinding = child.getValueBinding("value");
     return new ValueBindingComparator(facesContext, var, valueBinding, descending, comparator);
   }
+
+  public static void addBindingOrExpressionPopupActionListener(ActionSource actionSource, Object bindingOrExpression) {
+    actionSource.addActionListener(new ValueBindingPopupActionListener((ValueBinding) bindingOrExpression));
+  }
 }

Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java?rev=887996&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java Mon Dec  7 16:50:02 2009
@@ -0,0 +1,62 @@
+/*
+ * Created by IntelliJ IDEA.
+ * User: bommel
+ * Date: Dec 4, 2009
+ * Time: 5:36:37 PM
+ */
+package org.apache.myfaces.tobago.event;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.util.ComponentFindUtils;
+
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.el.ValueBinding;
+import javax.faces.event.ActionEvent;
+
+public class ValueBindingPopupActionListener extends AbstractPopupActionListener implements StateHolder {
+
+  private static final Log LOG = LogFactory.getLog(ValueBindingPopupActionListener.class);
+
+  private ValueBinding popupIdBinding;
+
+  public ValueBindingPopupActionListener(Object binding) {
+    popupIdBinding = (ValueBinding) binding;
+  }
+
+  @Override
+  protected UIComponent getPopup(ActionEvent actionEvent) {
+    String id = (String) popupIdBinding.getValue(FacesContext.getCurrentInstance());
+    UIComponent popup = ComponentFindUtils.findComponent(actionEvent.getComponent(), id);
+    if (popup == null) {
+      LOG.error("Found no popup for \""
+          + popupIdBinding.getExpressionString() + "\" := \""
+          + id + "\"! Search base componentId : "
+          + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
+    }
+    return popup;
+  }
+
+  public boolean isTransient() {
+    return false;
+  }
+
+  public void restoreState(FacesContext context, Object state) {
+    Object values[] = (Object[]) state;
+    popupIdBinding = (ValueBinding) UIComponentBase.restoreAttachedState(context, values[0]);
+  }
+
+  public Object saveState(FacesContext context) {
+    Object values[] = new Object[1];
+    values[0] = UIComponentBase.saveAttachedState(context, popupIdBinding);
+    return values;
+  }
+
+
+  public void setTransient(boolean newTransientValue) {
+    // ignore
+  }
+}
\ No newline at end of file

Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.1/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Modified: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/compat/FacesUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/compat/FacesUtils.java?rev=887996&r1=887995&r2=887996&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/compat/FacesUtils.java (original)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/compat/FacesUtils.java Mon Dec  7 16:50:02 2009
@@ -20,14 +20,17 @@
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.myfaces.tobago.event.TabChangeSource;
+import org.apache.myfaces.tobago.event.ValueExpressionPopupActionListener;
 import org.apache.myfaces.tobago.event.ValueExpressionTabChangeListener;
 import org.apache.myfaces.tobago.util.ValueExpressionComparator;
 
 import javax.el.MethodExpression;
 import javax.el.ValueExpression;
+import javax.faces.component.ActionSource;
 import javax.faces.component.ContextCallback;
 import javax.faces.component.EditableValueHolder;
 import javax.faces.component.NamingContainer;
+import javax.faces.component.UICommand;
 import javax.faces.component.UIComponent;
 import javax.faces.component.ValueHolder;
 import javax.faces.context.FacesContext;
@@ -166,4 +169,8 @@
     ValueExpression valueBinding = child.getValueExpression("value");
     return new ValueExpressionComparator(facesContext, var, valueBinding, descending, comparator);
   }
+
+  public static void addBindingOrExpressionPopupActionListener(ActionSource actionSource, Object bindingOrExpression) {
+    actionSource.addActionListener(new ValueExpressionPopupActionListener((ValueExpression) bindingOrExpression));
+  }
 }

Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java?rev=887996&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java Mon Dec  7 16:50:02 2009
@@ -0,0 +1,57 @@
+package org.apache.myfaces.tobago.event;
+
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+import org.apache.myfaces.tobago.util.ComponentFindUtils;
+
+import javax.el.ValueExpression;
+import javax.faces.component.StateHolder;
+import javax.faces.component.UIComponent;
+import javax.faces.component.UIComponentBase;
+import javax.faces.context.FacesContext;
+import javax.faces.event.ActionEvent;
+
+
+public class ValueExpressionPopupActionListener extends AbstractPopupActionListener implements StateHolder {
+
+  private static final Log LOG = LogFactory.getLog(ValueExpressionPopupActionListener.class);
+
+  private ValueExpression popupIdExpression;
+
+  public ValueExpressionPopupActionListener(Object expression) {
+    popupIdExpression = (ValueExpression) expression;
+  }
+
+  @Override
+  protected UIComponent getPopup(ActionEvent actionEvent) {
+    String id = (String) popupIdExpression.getValue(FacesContext.getCurrentInstance().getELContext());
+    UIComponent popup = ComponentFindUtils.findComponent(actionEvent.getComponent(), id);
+    if (popup == null) {
+      LOG.error("Found no popup for \""
+          + popupIdExpression.getExpressionString() + "\" := \""
+          + id + "\"! Search base componentId : "
+          + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
+    }
+    return popup;
+  }
+
+  public boolean isTransient() {
+    return false;
+  }
+
+  public void restoreState(FacesContext context, Object state) {
+    Object values[] = (Object[]) state;
+    popupIdExpression = (ValueExpression) UIComponentBase.restoreAttachedState(context, values[0]);
+  }
+
+  public Object saveState(FacesContext context) {
+    Object values[] = new Object[1];
+    values[0] = UIComponentBase.saveAttachedState(context, popupIdExpression);
+    return values;
+  }
+
+
+  public void setTransient(boolean newTransientValue) {
+    // ignore
+  }
+}
\ No newline at end of file

Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java-jsf-1.2/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java?rev=887996&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java Mon Dec  7 16:50:02 2009
@@ -0,0 +1,41 @@
+/*
+ * Created by IntelliJ IDEA.
+ * User: bommel
+ * Date: Dec 4, 2009
+ * Time: 5:10:57 PM
+ */
+package org.apache.myfaces.tobago.event;
+
+import org.apache.commons.beanutils.BeanUtils;
+import org.apache.commons.logging.Log;
+import org.apache.commons.logging.LogFactory;
+
+import javax.faces.component.UIComponent;
+import javax.faces.context.FacesContext;
+import javax.faces.event.AbortProcessingException;
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+import java.lang.reflect.InvocationTargetException;
+
+public abstract class AbstractPopupActionListener implements ActionListener {
+  private static final Log LOG = LogFactory.getLog(AbstractPopupActionListener.class);
+
+  public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
+    UIComponent popup = getPopup(actionEvent);
+    if (popup != null) {
+      if (LOG.isDebugEnabled()) {
+        LOG.debug("activated "
+            + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
+      }
+      try {
+        BeanUtils.setProperty(popup, "activated", true);
+      } catch (IllegalAccessException e) {
+        LOG.error("", e);
+      } catch (InvocationTargetException e) {
+        LOG.error("", e);
+      }
+    }
+  }
+
+  protected abstract UIComponent getPopup(ActionEvent actionEvent);
+}
\ No newline at end of file

Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL

Added: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComponentFindUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComponentFindUtils.java?rev=887996&view=auto
==============================================================================
--- myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComponentFindUtils.java (added)
+++ myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComponentFindUtils.java Mon Dec  7 16:50:02 2009
@@ -0,0 +1,41 @@
+/*
+ * Created by IntelliJ IDEA.
+ * User: bommel
+ * Date: Dec 4, 2009
+ * Time: 6:16:49 PM
+ */
+package org.apache.myfaces.tobago.util;
+
+import javax.faces.component.NamingContainer;
+import javax.faces.component.UIComponent;
+
+public class ComponentFindUtils {
+   public static UIComponent findComponent(UIComponent from, String relativeId) {
+    int idLength = relativeId.length();
+    // Figure out how many colons
+    int colonCount = 0;
+    while (colonCount < idLength) {
+      if (relativeId.charAt(colonCount) != NamingContainer.SEPARATOR_CHAR) {
+        break;
+      }
+      colonCount++;
+    }
+
+    // colonCount == 0: fully relative
+    // colonCount == 1: absolute (still normal findComponent syntax)
+    // colonCount > 1: for each extra colon after 1, go up a naming container
+    // (to the view root, if naming containers run out)
+    if (colonCount > 1) {
+      relativeId = relativeId.substring(colonCount);
+      for (int j = 1; j < colonCount; j++) {
+        while (from.getParent() != null) {
+          from = from.getParent();
+          if (from instanceof NamingContainer) {
+            break;
+          }
+        }
+      }
+    }
+    return from.findComponent(relativeId);
+  }
+}
\ No newline at end of file

Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComponentFindUtils.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: myfaces/tobago/trunk/tobago-jsf-compat/src/main/java/org/apache/myfaces/tobago/util/ComponentFindUtils.java
------------------------------------------------------------------------------
    svn:keywords = Date Author Id Revision HeadURL