There are some action listeners that aren't being intercepted by my action-listener wrapper.  In particular,
I have a set of tabs that look like:
'
< tr:navigationPane hint = "tabs" >
<
tr:commandNavigationItem text = "Quad Based" selected ="#{tabNavigationBean.quadBased}" actionListener ="#{exRABean.laserDiagnosticsQuadBasedAction}" rendered ="#{navigationBean.laserDiagnostics}" ></ tr:commandNavigationItem >
...

The actionListener is being called, but not the wrapper action-listener defined in faces-config.xml.
I use similar things in other places and it works just fine.

This seems to happen when an underlying database table isn't there.  Perhaps Spring/JPA is getting in the way?

------------------------------------------------

import java.lang.reflect.Method;

public class ExceptionUtils {
          private ExceptionUtils() {
          }

             /**
            * Iterates through all root exceptions for the throwable entry and looks for
            * an exception that matches the given class (clazz). If this exception was
            * caused buy an exception of type clazz, that root exception is returned
            *
            * @param cause
            * @param clazz
            * @return
            */
          public static Throwable getException(Throwable cause, Class clazz) {
             Throwable throwable = null;
             do {
               Throwable nextCause;
               try {
                 Method rootCause = cause.getClass().getMethod("getRootCause", new Class[] {});
                 nextCause = (Throwable) rootCause.invoke(cause, new Object[] {});
               } catch (Exception e) {
                 nextCause = cause.getCause();
               }
               if (cause == nextCause) {
                 break;
               }

               if (nextCause != null && nextCause.getClass().equals(clazz)) {
                 throwable = nextCause;
                 break;
               }

               cause = nextCause;
             } while (cause != null);
             return throwable;
          }


}
-----------------------------------------

package gov.llnl.nif.dataviz.actionlistener.exceptionhandler;

import java.sql.SQLException;

import javax.faces.FacesException;
import javax.faces.application.FacesMessage;
import javax.faces.context.FacesContext;
import javax.faces.event.AbortProcessingException;
import javax.faces.event.ActionEvent;

import oracle.toplink.essentials.exceptions.DatabaseException;

import org.apache.log4j.Logger;
import org.apache.myfaces.application.ActionListenerImpl;

public class ExceptionHandlingActionListener extends ActionListenerImpl {
         private static Logger log = Logger.getLogger(ExceptionHandlingActionListener.class);

          public String oneLiner(String s) {
                   String [] lines = s.split("[\r\n]+");
                   StringBuilder sb = new StringBuilder();
                   for (String line : lines) {
                            sb.append(line);
                   }
                   return sb.toString();
          }
          public void processAction(ActionEvent event) throws AbortProcessingException {
             FacesContext facesContext = FacesContext.getCurrentInstance();
             try {

               super.processAction(event);
             } catch (FacesException fe) {     
               Throwable databaseException = ExceptionUtils.getException(fe, DatabaseException.class);
               if (databaseException != null) {
                FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR,"Database Error",oneLiner(databaseException.getMessage()));
                facesContext.addMessage(null, facesMessage);
               } else {
                   databaseException = ExceptionUtils.getException(fe, SQLException.class);
                   if (databaseException != null) {
                           FacesMessage facesMessage = new FacesMessage(FacesMessage.SEVERITY_ERROR, "SQL Database error", oneLiner(databaseException.getMessage()));
                           facesContext.addMessage(null, facesMessage);
                   } else {
                           throw fe;
                   }
                }
             }
          }

}
----------------------------------------
from faces-config.xml

< application >
  < action-listener >
           gov.llnl.nif.dataviz.actionlistener.exceptionhandler.ExceptionHandlingActionListener
 
</ action-listener >
 
 
< default-render-kit-id > org.apache.myfaces.trinidad.core </ default-render-kit-id >
<
variable-resolver > org.springframework.web.jsf.DelegatingVariableResolver </ variable-resolver >
  <!--     <navigation-handler>org.springframework.webflow.executor.jsf.FlowNavigationHandler</navigation-handler>
  <variable-resolver>org.springframework.webflow.executor.jsf.DelegatingFlowVariableResolver</variable-resolver>
-->
  < locale-config >
  < default-locale > en </ default-locale >
  < supported-locale > en </ supported-locale >
  < supported-locale > es </ supported-locale >
  < supported-locale > de </ supported-locale >
  < supported-locale > fr </ supported-locale >
  < supported-locale > nl </ supported-locale >
  < supported-locale > pt_BR </ supported-locale >
  < supported-locale > zh_CN </ supported-locale >
  </ locale-config >
</
application >

Reply via email to