Coverage Report - org.seasar.teeda.core.application.ActionListenerImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionListenerImpl
0%
0/30
0%
0/4
2.5
 
 1  
 /*
 2  
  * Copyright 2004-2011 the Seasar Foundation and the Others.
 3  
  *
 4  
  * Licensed under the Apache License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  *     http://www.apache.org/licenses/LICENSE-2.0
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
 13  
  * either express or implied. See the License for the specific language
 14  
  * governing permissions and limitations under the License.
 15  
  */
 16  
 package org.seasar.teeda.core.application;
 17  
 
 18  
 import java.io.IOException;
 19  
 
 20  
 import javax.faces.component.ActionSource;
 21  
 import javax.faces.context.ExternalContext;
 22  
 import javax.faces.context.FacesContext;
 23  
 import javax.faces.el.EvaluationException;
 24  
 import javax.faces.el.MethodBinding;
 25  
 import javax.faces.event.AbortProcessingException;
 26  
 import javax.faces.event.ActionEvent;
 27  
 import javax.faces.event.ActionListener;
 28  
 
 29  
 import org.seasar.framework.log.Logger;
 30  
 import org.seasar.teeda.core.util.ErrorPageManager;
 31  
 import org.seasar.teeda.core.util.MethodBindingUtil;
 32  
 import org.seasar.teeda.core.util.NavigationHandlerUtil;
 33  
 import org.seasar.teeda.core.util.NullErrorPageManagerImpl;
 34  
 
 35  
 /**
 36  
  * @author higa
 37  
  */
 38  0
 public class ActionListenerImpl implements ActionListener {
 39  
 
 40  0
     private static Logger logger = Logger.getLogger(ActionListenerImpl.class);
 41  
 
 42  
     public static final String errorManager_BINDING = "bindingType=may";
 43  
 
 44  0
     private ErrorPageManager errorPageManager = new NullErrorPageManagerImpl();
 45  
 
 46  
     public void processAction(ActionEvent actionEvent)
 47  
             throws AbortProcessingException {
 48  0
         FacesContext context = FacesContext.getCurrentInstance();
 49  0
         ActionSource actionSource = (ActionSource) actionEvent.getComponent();
 50  0
         MethodBinding mb = actionSource.getAction();
 51  0
         String fromAction = null;
 52  0
         String outcome = null;
 53  0
         if (mb != null) {
 54  0
             fromAction = mb.getExpressionString();
 55  
             try {
 56  0
                 outcome = MethodBindingUtil.invoke(mb, context);
 57  0
                 processAfterInvoke(context, fromAction, outcome);
 58  0
             } catch (EvaluationException ex) {
 59  0
                 Throwable cause = ex.getCause();
 60  
                 try {
 61  0
                     ExternalContext extContext = context.getExternalContext();
 62  0
                     if (errorPageManager.handleException(cause, context,
 63  
                             extContext)) {
 64  0
                         context.responseComplete();
 65  
                     } else {
 66  0
                         throw ex;
 67  
                     }
 68  0
                 } catch (IOException ioe) {
 69  0
                     logger.log(ioe);
 70  0
                     throw ex;
 71  0
                 }
 72  0
             }
 73  
         }
 74  0
         NavigationHandlerUtil.handleNavigation(context, fromAction, outcome);
 75  0
         context.renderResponse();
 76  0
     }
 77  
 
 78  
     protected void processAfterInvoke(FacesContext context, String fromAction,
 79  
             String outcome) {
 80  0
     }
 81  
 
 82  
     public ErrorPageManager getErrorPageManager() {
 83  0
         return errorPageManager;
 84  
     }
 85  
 
 86  
     public void setErrorPageManager(ErrorPageManager errorPageManager) {
 87  0
         this.errorPageManager = errorPageManager;
 88  0
     }
 89  
 
 90  
 }