You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by lo...@apache.org on 2013/10/07 15:04:44 UTC

svn commit: r1529833 - in /myfaces/tobago/trunk: tobago-core/src/main/java/org/apache/myfaces/tobago/event/ tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/ tobago-core/src/main/java/org/apache/myfaces/tobago/util/ tobago-extension/...

Author: lofwyr
Date: Mon Oct  7 13:04:44 2013
New Revision: 1529833

URL: http://svn.apache.org/r1529833
Log:
cleaning up
reduce dependencies

Added:
    myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java
      - copied, changed from r1529778, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java
    myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/ValueBindingResetInputActionListener.java
      - copied unchanged from r1529778, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueBindingResetInputActionListener.java
    myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/ValueBindingTabChangeListener.java
      - copied unchanged from r1529778, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueBindingTabChangeListener.java
Removed:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueBindingResetInputActionListener.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueBindingTabChangeListener.java
Modified:
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java
    myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageUtils.java

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java?rev=1529833&r1=1529832&r2=1529833&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/AbstractPopupActionListener.java Mon Oct  7 13:04:44 2013
@@ -19,38 +19,29 @@
 
 package org.apache.myfaces.tobago.event;
 
-import org.apache.commons.beanutils.BeanUtils;
+import org.apache.myfaces.tobago.internal.component.AbstractUIPopup;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-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 Logger LOG = LoggerFactory.getLogger(AbstractPopupActionListener.class);
 
   public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
-    UIComponent popup = getPopup(actionEvent);
+    AbstractUIPopup popup = getPopup(actionEvent);
     if (popup != null) {
       if (LOG.isDebugEnabled()) {
-        LOG.debug("activated "
-            + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
-      }
-      // XXX this is called via reflection, because the class AbstractUIPopup is not available here.
-      try {
-        BeanUtils.setProperty(popup, "activated", true);
-      } catch (IllegalAccessException e) {
-        LOG.error("", e);
-      } catch (InvocationTargetException e) {
-        LOG.error("", e);
+        LOG.debug("Setting activated for component: clientId='"
+            + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()) + "'");
       }
+      popup.setActivated(true);
     }
   }
 
-  protected abstract UIComponent getPopup(ActionEvent actionEvent);
+  protected abstract AbstractUIPopup getPopup(ActionEvent actionEvent);
 }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java?rev=1529833&r1=1529832&r2=1529833&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/PopupFacetActionListener.java Mon Oct  7 13:04:44 2013
@@ -33,12 +33,15 @@ public class PopupFacetActionListener ex
   private static final Logger LOG = LoggerFactory.getLogger(PopupActionListener.class);
 
   @Override
-  protected UIComponent getPopup(ActionEvent actionEvent) {
+  protected AbstractUIPopup getPopup(ActionEvent actionEvent) {
     UIComponent component = actionEvent.getComponent().getFacet(Facets.POPUP);
     if (component instanceof AbstractUIPopup) {
-      return component;
+      return (AbstractUIPopup) component;
+    } else if (component != null) {
+      LOG.error("Found wrong type='" + component.getClass().getName() + "' in popup facet of component "
+          + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
     } else {
-      LOG.error("Found no popup facet in component "
+      LOG.error("Found no popup facet of component "
           + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
     }
     return null;

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java?rev=1529833&r1=1529832&r2=1529833&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueExpressionPopupActionListener.java Mon Oct  7 13:04:44 2013
@@ -19,6 +19,7 @@
 
 package org.apache.myfaces.tobago.event;
 
+import org.apache.myfaces.tobago.internal.component.AbstractUIPopup;
 import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -56,16 +57,18 @@ public class ValueExpressionPopupActionL
   }
 
   @Override
-  protected UIComponent getPopup(ActionEvent actionEvent) {
+  protected AbstractUIPopup getPopup(ActionEvent actionEvent) {
     String id = (String) popupIdExpression.getValue(FacesContext.getCurrentInstance().getELContext());
     UIComponent popup = FindComponentUtils.findComponent(actionEvent.getComponent(), id);
-    if (popup == null) {
+    if (popup instanceof AbstractUIPopup) {
+      return (AbstractUIPopup) popup;
+    } else {
       LOG.error("Found no popup for \""
           + popupIdExpression.getExpressionString() + "\" := \""
           + id + "\"! Search base componentId : "
           + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
+      return null;
     }
-    return popup;
   }
 
   public boolean isTransient() {

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java?rev=1529833&r1=1529832&r2=1529833&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/config/TobagoConfigImpl.java Mon Oct  7 13:04:44 2013
@@ -19,7 +19,6 @@
 
 package org.apache.myfaces.tobago.internal.config;
 
-import org.apache.commons.beanutils.PropertyUtils;
 import org.apache.myfaces.tobago.application.ProjectStage;
 import org.apache.myfaces.tobago.config.TobagoConfig;
 import org.apache.myfaces.tobago.context.Theme;
@@ -242,15 +241,14 @@ public class TobagoConfigImpl extends To
     if (facesContext != null) {
       try {
         final Application application = facesContext.getApplication();
-        final Map<String, String> map;
-        map = (Map<String, String>) PropertyUtils.getProperty(application, "defaultValidatorInfo");
-        if (application != null && map.size() > 0) {
+        final Map<String, String> map = application.getDefaultValidatorInfo();
+        if (map.size() > 0) {
           defaultValidatorInfo = Collections.unmodifiableMap(map);
         } else {
           defaultValidatorInfo = Collections.emptyMap();
         }
       } catch (Exception e) {
-        // should not happen
+        // should not happen (occurred with JBoss GateIn 3.6.0)
         LOG.error("Can't initialize default validators.", e);
         defaultValidatorInfo = Collections.emptyMap();
       }

Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageUtils.java?rev=1529833&r1=1529832&r2=1529833&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/MessageUtils.java Mon Oct  7 13:04:44 2013
@@ -19,10 +19,8 @@
 
 package org.apache.myfaces.tobago.util;
 
-import org.apache.commons.beanutils.ConstructorUtils;
 import org.apache.myfaces.tobago.application.LabelValueExpressionFacesMessage;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
+import org.apache.myfaces.tobago.context.TobagoResourceBundle;
 
 import javax.el.ValueExpression;
 import javax.faces.application.FacesMessage;
@@ -44,8 +42,6 @@ import java.util.ResourceBundle;
  */
 public class MessageUtils {
 
-  private static final Logger LOG = LoggerFactory.getLogger(MessageUtils.class);
-
   private static final String DETAIL_SUFFIX = "_detail";
 
   private MessageUtils() {
@@ -67,7 +63,7 @@ public class MessageUtils {
     String detail = getBundleString(appBundle, messageId + DETAIL_SUFFIX);
 
     if (summary == null || detail == null) {
-      ResourceBundle tobagoBundle = getTobagoBundle();
+      ResourceBundle tobagoBundle = new TobagoResourceBundle();
       if (summary == null) {
         summary = getBundleString(tobagoBundle, messageId);
       }
@@ -120,25 +116,6 @@ public class MessageUtils {
     return bundleName != null ? getBundle(facesContext, locale, bundleName) : null;
   }
 
-  private static ResourceBundle getTobagoBundle() {
-    // XXX This is ugly, can be removed after merging tobago-jsf-compat to tobago-core
-    try {
-      Class clazz = Class.forName("org.apache.myfaces.tobago.context.TobagoResourceBundle");
-      Object bundle = ConstructorUtils.invokeConstructor(clazz, new Object[0]);
-      LOG.error("*********************************************************************************************");
-      LOG.error("*********************************************************************************************");
-      LOG.error("*********************************************************************************************");
-      LOG.error("just created: " + bundle + " " + System.identityHashCode(bundle));
-      LOG.error("*********************************************************************************************");
-      LOG.error("*********************************************************************************************");
-      LOG.error("*********************************************************************************************");
-      return (ResourceBundle) bundle;
-    } catch (Exception e) {
-      LOG.error("Can't create TobagoResourceBundle, but it should be in the core.", e);
-      return null; // should not be possible.
-    }
-  }
-
   private static ResourceBundle getDefaultBundle(FacesContext facesContext, Locale locale) {
     return getBundle(facesContext, locale, FacesMessage.FACES_MESSAGES);
   }
@@ -169,7 +146,7 @@ public class MessageUtils {
   }
 
   /**
-   * @deprecated
+   * @deprecated Since Tobago 2.0.0
    */
   @Deprecated
   public static String getFormatedMessage(String message, Locale locale, Object... args) {

Copied: myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java (from r1529778, myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java)
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java?p2=myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java&p1=myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java&r1=1529778&r2=1529833&rev=1529833&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java (original)
+++ myfaces/tobago/trunk/tobago-extension/tobago-deprecation/src/main/java/org/apache/myfaces/tobago/event/ValueBindingPopupActionListener.java Mon Oct  7 13:04:44 2013
@@ -19,6 +19,7 @@
 
 package org.apache.myfaces.tobago.event;
 
+import org.apache.myfaces.tobago.internal.component.AbstractUIPopup;
 import org.apache.myfaces.tobago.internal.util.FindComponentUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
@@ -51,16 +52,18 @@ public class ValueBindingPopupActionList
   }
 
   @Override
-  protected UIComponent getPopup(ActionEvent actionEvent) {
+  protected AbstractUIPopup getPopup(ActionEvent actionEvent) {
     String id = (String) popupIdBinding.getValue(FacesContext.getCurrentInstance());
     UIComponent popup = FindComponentUtils.findComponent(actionEvent.getComponent(), id);
-    if (popup == null) {
+    if (popup instanceof AbstractUIPopup) {
+      return (AbstractUIPopup) popup;
+    } else {
       LOG.error("Found no popup for \""
           + popupIdBinding.getExpressionString() + "\" := \""
           + id + "\"! Search base componentId : "
           + actionEvent.getComponent().getClientId(FacesContext.getCurrentInstance()));
+      return null;
     }
-    return popup;
   }
 
   public boolean isTransient() {