Coverage Report - org.apache.tapestry5.corelib.internal.WrappedComponentAction
 
Classes in this File Line Coverage Branch Coverage Complexity
WrappedComponentAction
0%
0/9
N/A
1
 
 1  
 // Copyright 2008 The Apache Software Foundation
 2  
 //
 3  
 // Licensed under the Apache License, Version 2.0 (the "License");
 4  
 // you may not use this file except in compliance with the License.
 5  
 // You may obtain a copy of the License at
 6  
 //
 7  
 //     http://www.apache.org/licenses/LICENSE-2.0
 8  
 //
 9  
 // Unless required by applicable law or agreed to in writing, software
 10  
 // distributed under the License is distributed on an "AS IS" BASIS,
 11  
 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 12  
 // See the License for the specific language governing permissions and
 13  
 // limitations under the License.
 14  
 
 15  
 package org.apache.tapestry5.corelib.internal;
 16  
 
 17  
 import org.apache.tapestry5.ComponentAction;
 18  
 import org.apache.tapestry5.runtime.Component;
 19  
 import org.apache.tapestry5.services.ComponentSource;
 20  
 
 21  
 import java.io.Serializable;
 22  
 
 23  
 /**
 24  
  * A wrapper around a component id and a {@link org.apache.tapestry5.ComponentAction}.
 25  
  *
 26  
  * @see org.apache.tapestry5.corelib.components.FormFragment
 27  
  */
 28  
 public class WrappedComponentAction implements Serializable
 29  
 {
 30  
     private final String componentId;
 31  
 
 32  
     private final ComponentAction action;
 33  
 
 34  
     public WrappedComponentAction(Component component, ComponentAction action)
 35  
     {
 36  0
         this(component.getComponentResources().getCompleteId(), action);
 37  0
     }
 38  
 
 39  
     /**
 40  
      * @param componentId the component's complete id, suitable for use with {@link org.apache.tapestry5.services.ComponentSource#getComponent(String)}.
 41  
      * @param action      the action associated with the component
 42  
      */
 43  
     public WrappedComponentAction(String componentId, ComponentAction action)
 44  0
     {
 45  0
         this.componentId = componentId;
 46  0
         this.action = action;
 47  0
     }
 48  
 
 49  
     /**
 50  
      * Retrieves the component from the source and executes the action.
 51  
      *
 52  
      * @param source used to re-acquire the component
 53  
      */
 54  
     public void execute(ComponentSource source)
 55  
     {
 56  0
         Component component = source.getComponent(componentId);
 57  
 
 58  0
         action.execute(component);
 59  0
     }
 60  
 }