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 2010/08/13 14:39:35 UTC
svn commit: r985178 - in
/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago:
internal/component/ util/ validator/
Author: lofwyr
Date: Fri Aug 13 12:39:35 2010
New Revision: 985178
URL: http://svn.apache.org/viewvc?rev=985178&view=rev
Log:
clean up: add util-method for invoke method binding with an event
Modified:
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/validator/ClearValidatorsActionListener.java
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java?rev=985178&r1=985177&r2=985178&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUISheet.java Fri Aug 13 12:39:35 2010
@@ -39,6 +39,7 @@ import org.apache.myfaces.tobago.layout.
import org.apache.myfaces.tobago.layout.LayoutTokens;
import org.apache.myfaces.tobago.model.SheetState;
import org.apache.myfaces.tobago.renderkit.LayoutComponentRenderer;
+import org.apache.myfaces.tobago.util.ComponentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -47,7 +48,6 @@ import javax.faces.component.ContextCall
import javax.faces.component.UIColumn;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
@@ -331,39 +331,24 @@ public abstract class AbstractUISheet ex
public void broadcast(FacesEvent facesEvent) throws AbortProcessingException {
super.broadcast(facesEvent);
if (facesEvent instanceof SheetStateChangeEvent) {
- invokeMethodBinding(getStateChangeListener(), facesEvent);
+ ComponentUtils.invokeMethodBinding(getFacesContext(), getStateChangeListener(), facesEvent);
} else if (facesEvent instanceof PageActionEvent) {
if (facesEvent.getComponent() == this) {
performPaging((PageActionEvent) facesEvent);
- invokeMethodBinding(getStateChangeListener(), new SheetStateChangeEvent(this));
+ ComponentUtils.invokeMethodBinding(
+ getFacesContext(), getStateChangeListener(), new SheetStateChangeEvent(this));
}
} else if (facesEvent instanceof SortActionEvent) {
getSheetState(getFacesContext()).updateSortState((SortActionEvent) facesEvent);
MethodBinding methodBinding = getSortActionListener();
if (methodBinding!= null) {
- invokeMethodBinding(methodBinding, facesEvent);
+ ComponentUtils.invokeMethodBinding(getFacesContext(), methodBinding, facesEvent);
} else {
new Sorter().perform((SortActionEvent) facesEvent);
}
}
}
- private void invokeMethodBinding(MethodBinding methodBinding, FacesEvent event) {
- if (methodBinding != null && event != null) {
- try {
- Object[] objects = new Object[]{event};
- methodBinding.invoke(getFacesContext(), objects);
- } catch (EvaluationException e) {
- Throwable cause = e.getCause();
- if (cause instanceof AbortProcessingException) {
- throw (AbortProcessingException) cause;
- } else {
- throw e;
- }
- }
- }
- }
-
public void addStateChangeListener(SheetStateChangeListener listener) {
addFacesListener(listener);
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java?rev=985178&r1=985177&r2=985178&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITabGroup.java Fri Aug 13 12:39:35 2010
@@ -17,8 +17,6 @@ package org.apache.myfaces.tobago.intern
* limitations under the License.
*/
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
import org.apache.myfaces.tobago.compat.FacesUtils;
import org.apache.myfaces.tobago.component.Attributes;
import org.apache.myfaces.tobago.component.ComponentTypes;
@@ -33,12 +31,13 @@ import org.apache.myfaces.tobago.interna
import org.apache.myfaces.tobago.layout.LayoutComponent;
import org.apache.myfaces.tobago.layout.LayoutContainer;
import org.apache.myfaces.tobago.layout.LayoutManager;
+import org.apache.myfaces.tobago.util.ComponentUtils;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import javax.faces.component.ActionSource;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
-import javax.faces.el.MethodBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
@@ -202,35 +201,12 @@ public abstract class AbstractUITabGroup
} else {
setSelectedIndex(index);
}
- MethodBinding tabChangeListenerBinding = getTabChangeListener();
- if (tabChangeListenerBinding != null) {
- try {
- tabChangeListenerBinding.invoke(getFacesContext(), new Object[]{facesEvent});
- } catch (EvaluationException e) {
- Throwable cause = e.getCause();
- if (cause != null && cause instanceof AbortProcessingException) {
- throw (AbortProcessingException) cause;
- } else {
- throw e;
- }
- }
- }
- MethodBinding actionListenerBinding = getActionListener();
- if (actionListenerBinding != null) {
- try {
- actionListenerBinding.invoke(getFacesContext(), new Object[]{facesEvent});
- } catch (EvaluationException e) {
- Throwable cause = e.getCause();
- if (cause != null && cause instanceof AbortProcessingException) {
- throw (AbortProcessingException) cause;
- } else {
- throw e;
- }
- }
- }
- ActionListener defaultActionListener
- = getFacesContext().getApplication().getActionListener();
+ ComponentUtils.invokeMethodBinding(getFacesContext(), getTabChangeListener(), facesEvent);
+
+ ComponentUtils.invokeMethodBinding(getFacesContext(), getActionListener(), facesEvent);
+
+ ActionListener defaultActionListener = getFacesContext().getApplication().getActionListener();
if (defaultActionListener != null) {
defaultActionListener.processAction((ActionEvent) facesEvent);
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java?rev=985178&r1=985177&r2=985178&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/internal/component/AbstractUITreeNode.java Fri Aug 13 12:39:35 2010
@@ -24,13 +24,13 @@ import org.apache.myfaces.tobago.event.T
import org.apache.myfaces.tobago.event.TreeExpansionListener;
import org.apache.myfaces.tobago.model.MixedTreeModel;
import org.apache.myfaces.tobago.model.TreePath;
+import org.apache.myfaces.tobago.util.ComponentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import javax.faces.component.UIComponent;
import javax.faces.component.UIOutput;
import javax.faces.context.FacesContext;
-import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.FacesEvent;
@@ -210,22 +210,7 @@ public abstract class AbstractUITreeNode
public void broadcast(FacesEvent event) throws AbortProcessingException {
super.broadcast(event);
if (event instanceof TreeExpansionEvent) {
- invokeMethodBinding(getTreeExpansionListener(), event);
- }
- }
-
- private void invokeMethodBinding(MethodBinding methodBinding, FacesEvent event) {
- if (methodBinding != null && event != null) {
- try {
- methodBinding.invoke(getFacesContext(), new Object[]{event});
- } catch (EvaluationException e) {
- Throwable cause = e.getCause();
- if (cause instanceof AbortProcessingException) {
- throw (AbortProcessingException) cause;
- } else {
- throw e;
- }
- }
+ ComponentUtils.invokeMethodBinding(getFacesContext(), getTreeExpansionListener(), event);
}
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java?rev=985178&r1=985177&r2=985178&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/util/ComponentUtils.java Fri Aug 13 12:39:35 2010
@@ -51,10 +51,13 @@ import javax.faces.component.UISelectMan
import javax.faces.component.ValueHolder;
import javax.faces.context.FacesContext;
import javax.faces.convert.Converter;
+import javax.faces.el.EvaluationException;
import javax.faces.el.MethodBinding;
import javax.faces.el.ValueBinding;
+import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;
import javax.faces.event.ActionListener;
+import javax.faces.event.FacesEvent;
import javax.faces.event.ValueChangeEvent;
import javax.faces.model.SelectItem;
import javax.faces.render.RenderKit;
@@ -871,4 +874,19 @@ public class ComponentUtils {
}
return null;
}
+
+ public static void invokeMethodBinding(FacesContext facesContext, MethodBinding methodBinding, FacesEvent event) {
+ if (methodBinding != null && event != null) {
+ try {
+ methodBinding.invoke(facesContext, new Object[]{event});
+ } catch (EvaluationException e) {
+ Throwable cause = e.getCause();
+ if (cause instanceof AbortProcessingException) {
+ throw (AbortProcessingException) cause;
+ } else {
+ throw e;
+ }
+ }
+ }
+ }
}
Modified: myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/validator/ClearValidatorsActionListener.java
URL: http://svn.apache.org/viewvc/myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/validator/ClearValidatorsActionListener.java?rev=985178&r1=985177&r2=985178&view=diff
==============================================================================
--- myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/validator/ClearValidatorsActionListener.java (original)
+++ myfaces/tobago/trunk/tobago-core/src/main/java/org/apache/myfaces/tobago/validator/ClearValidatorsActionListener.java Fri Aug 13 12:39:35 2010
@@ -22,9 +22,9 @@ package org.apache.myfaces.tobago.valida
* $Id$
*/
+import org.apache.myfaces.tobago.util.ComponentUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import org.apache.myfaces.tobago.util.ComponentUtils;
import javax.faces.component.UIComponent;
import javax.faces.context.FacesContext;
@@ -36,15 +36,13 @@ import java.util.StringTokenizer;
public class ClearValidatorsActionListener implements ActionListener {
- private static final Logger LOG
- = LoggerFactory.getLogger(ClearValidatorsActionListener.class);
+ private static final Logger LOG = LoggerFactory.getLogger(ClearValidatorsActionListener.class);
public PhaseId getPhaseId() {
return PhaseId.APPLY_REQUEST_VALUES;
}
- public void processAction(ActionEvent actionEvent)
- throws AbortProcessingException {
+ public void processAction(ActionEvent actionEvent) throws AbortProcessingException {
if (LOG.isDebugEnabled()) {
LOG.debug("actionEvent = '" + actionEvent + "'");
}