Coverage Report - org.apache.myfaces.application.ActionListenerImpl
 
Classes in this File Line Coverage Branch Coverage Complexity
ActionListenerImpl
0%
0/24
0%
0/8
9
 
 1  
 /*
 2  
  * Licensed to the Apache Software Foundation (ASF) under one
 3  
  * or more contributor license agreements.  See the NOTICE file
 4  
  * distributed with this work for additional information
 5  
  * regarding copyright ownership.  The ASF licenses this file
 6  
  * to you under the Apache License, Version 2.0 (the
 7  
  * "License"); you may not use this file except in compliance
 8  
  * with the License.  You may obtain a copy of the License at
 9  
  *
 10  
  *   http://www.apache.org/licenses/LICENSE-2.0
 11  
  *
 12  
  * Unless required by applicable law or agreed to in writing,
 13  
  * software distributed under the License is distributed on an
 14  
  * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 15  
  * KIND, either express or implied.  See the License for the
 16  
  * specific language governing permissions and limitations
 17  
  * under the License.
 18  
  */
 19  
 package org.apache.myfaces.application;
 20  
 
 21  
 import javax.faces.FacesException;
 22  
 import javax.faces.application.Application;
 23  
 import javax.faces.application.NavigationHandler;
 24  
 import javax.faces.component.ActionSource;
 25  
 import javax.faces.context.FacesContext;
 26  
 import javax.faces.el.EvaluationException;
 27  
 import javax.faces.el.MethodBinding;
 28  
 import javax.faces.event.AbortProcessingException;
 29  
 import javax.faces.event.ActionEvent;
 30  
 import javax.faces.event.ActionListener;
 31  
 
 32  
 
 33  
 /**
 34  
  * @author Manfred Geiler (latest modification by $Author: skitching $)
 35  
  * @author Anton Koinov
 36  
  * @version $Revision: 684459 $ $Date: 2008-08-10 06:13:56 -0500 (Sun, 10 Aug 2008) $
 37  
  */
 38  0
 public class ActionListenerImpl
 39  
     implements ActionListener
 40  
 {
 41  
 
 42  
     public void processAction(ActionEvent actionEvent) throws AbortProcessingException
 43  
     {
 44  0
         FacesContext facesContext = FacesContext.getCurrentInstance();
 45  0
         Application application = facesContext.getApplication();
 46  
 
 47  0
         ActionSource actionSource = (ActionSource)actionEvent.getComponent();
 48  0
         MethodBinding methodBinding = actionSource.getAction();
 49  
 
 50  0
         String fromAction = null;
 51  0
         String outcome = null;
 52  0
         if (methodBinding != null)
 53  
         {
 54  0
             fromAction = methodBinding.getExpressionString();
 55  
             try
 56  
             {
 57  0
                 Object objOutcome = methodBinding.invoke(facesContext, null);
 58  
 
 59  0
                 if (objOutcome != null)
 60  
                 {
 61  0
                     outcome = objOutcome.toString();
 62  
                 }
 63  
             }
 64  0
             catch (EvaluationException e)
 65  
             {
 66  0
                 Throwable cause = e.getCause();
 67  0
                 if (cause != null && cause instanceof AbortProcessingException)
 68  
                 {
 69  0
                     throw (AbortProcessingException)cause;
 70  
                 }
 71  
    
 72  0
                 throw new FacesException("Error calling action method of component with id " + actionEvent.getComponent().getClientId(facesContext), e);
 73  
                 
 74  
             }
 75  0
             catch (RuntimeException e)
 76  
             {
 77  0
                 throw new FacesException("Error calling action method of component with id " + actionEvent.getComponent().getClientId(facesContext), e);
 78  0
             }
 79  
         }
 80  
 
 81  0
         NavigationHandler navigationHandler = application.getNavigationHandler();
 82  0
         navigationHandler.handleNavigation(facesContext,
 83  
                                            fromAction,
 84  
                                            outcome);
 85  
         //Render Response if needed
 86  0
         facesContext.renderResponse();
 87  
 
 88  0
     }
 89  
 }