You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@struts.apache.org by cr...@apache.org on 2006/07/01 08:03:42 UTC
svn commit: r418443 - in /struts/shale/trunk/shale-core/src/main:
java/org/apache/shale/view/faces/ViewActionListener.java
resources/META-INF/faces-config.xml
Author: craigmcc
Date: Fri Jun 30 23:03:41 2006
New Revision: 418443
URL: http://svn.apache.org/viewvc?rev=418443&view=rev
Log:
Contribute to SHALE-125 (consistent exception handling strategy) by wrapping
the call to the user's action method in a common exception handler.
Added:
struts/shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java (with props)
Modified:
struts/shale/trunk/shale-core/src/main/resources/META-INF/faces-config.xml
Added: struts/shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java
URL: http://svn.apache.org/viewvc/struts/shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java?rev=418443&view=auto
==============================================================================
--- struts/shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java (added)
+++ struts/shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java Fri Jun 30 23:03:41 2006
@@ -0,0 +1,95 @@
+/*
+ * Copyright 2006 The Apache Software Foundation.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * $Id$
+ */
+
+package org.apache.shale.view.faces;
+
+import javax.faces.event.ActionEvent;
+import javax.faces.event.ActionListener;
+
+/**
+ * <p>Replacement for the default <code>ActionListener</code> implementation
+ * used during the <em>Invoke Application</em> phase of the request processing
+ * lifecycle.</p>
+ *
+ * @since 1.0.3
+ */
+public final class ViewActionListener implements ActionListener {
+
+
+ // ------------------------------------------------------------- Constructor
+
+
+ /**
+ * <p>Create a new action listener instance.</p>
+ *
+ * @param original The original action listener instance we are wrapping
+ */
+ public ViewActionListener(ActionListener original) {
+ this.original = original;
+ }
+
+
+ // ------------------------------------------------------ Instance Variables
+
+
+ /**
+ * <p>The original <code>ActionListener</code> instance we are wrapping.</p>
+ */
+ private ActionListener original = null;
+
+
+ // -------------------------------------------------- ActionListener Methods
+
+
+ /**
+ * <p>Handle a default action event.</p>
+ *
+ * @param event The <code>ActionEvent</code> to be handled
+ */
+ public void processAction(ActionEvent event) {
+
+ // FIXME - this is probably not the final answer, but gives
+ // us a starting point to deal with application event handlers
+ // throwing exceptions in a way consistent with elsewhere
+ try {
+ original.processAction(event);
+ } catch (Exception e) {
+ handleException(e);
+ }
+
+ }
+
+
+ // --------------------------------------------------------- Private Methods
+
+
+ /**
+ * <p>Handle the specified exception according to the strategy
+ * defined by our current {@link ExceptionHandler}.</p>
+ *
+ * @param exception Exception to be handled
+ */
+ private void handleException(Exception exception) {
+
+ ExceptionHandlerFactory.getInstance().getExceptionHandler().
+ handleException(exception);
+
+ }
+
+
+}
Propchange: struts/shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: struts/shale/trunk/shale-core/src/main/java/org/apache/shale/view/faces/ViewActionListener.java
------------------------------------------------------------------------------
svn:keywords = Date Author Id Revision HeadURL
Modified: struts/shale/trunk/shale-core/src/main/resources/META-INF/faces-config.xml
URL: http://svn.apache.org/viewvc/struts/shale/trunk/shale-core/src/main/resources/META-INF/faces-config.xml?rev=418443&r1=418442&r2=418443&view=diff
==============================================================================
--- struts/shale/trunk/shale-core/src/main/resources/META-INF/faces-config.xml (original)
+++ struts/shale/trunk/shale-core/src/main/resources/META-INF/faces-config.xml Fri Jun 30 23:03:41 2006
@@ -34,6 +34,9 @@
<!-- Custom JSF Application Objects -->
<application>
+ <action-listener>
+ org.apache.shale.view.faces.ViewActionListener
+ </action-listener>
<navigation-handler>
org.apache.shale.dialog.faces.DialogNavigationHandler
</navigation-handler>