Coverage Report - org.apache.tapestry.internal.event.EventBoundListener
 
Classes in this File Line Coverage Branch Coverage Complexity
EventBoundListener
0%
0/47
0%
0/24
2.056
 
 1  
 // Copyright Jun 2, 2006 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  
 package org.apache.tapestry.internal.event;
 15  
 
 16  
 
 17  
 /**
 18  
  * Provides a mapping for listener methods that are bound to events, used
 19  
  * internally by {@link ComponentEventProperty}.
 20  
  */
 21  
 public class EventBoundListener implements Cloneable
 22  
 {
 23  
     // the method name to invoke
 24  
     private String _methodName;
 25  
     // if not null the form to submit before invoking listener
 26  
     private String _formId;
 27  
     // if _formId set whether or not to validate form when submitted
 28  
     private boolean _validateForm;
 29  
     // The targeted component to listen to events on
 30  
     private String _componentId;
 31  
     // The id path of the component that the listener method is connected to
 32  
     private String _componentIdPath;
 33  
     
 34  
     // If targeting a form, whether or not to submit it asynchronously
 35  
     private boolean _async;
 36  
     // Whether or not to focus the form
 37  
     private boolean _focus;
 38  
     // If this is an autoSubmit form bound event, ie we need to discover the formId dynamically
 39  
     private boolean _autoSubmit;
 40  
     
 41  
     /**
 42  
      * Creates a new listener binding. 
 43  
      * @param methodName
 44  
      *          The method to invoke.
 45  
      */
 46  
     public EventBoundListener(String methodName, String componentId)
 47  
     {
 48  0
         this(methodName, componentId, true);
 49  0
     }
 50  
 
 51  
     /**
 52  
      * Creates a new listener binding.
 53  
      * @param methodName
 54  
      *          The method to invoke.
 55  
      */
 56  
     public EventBoundListener(String methodName, String componentId, boolean autoSubmit)
 57  
     {
 58  0
         this(methodName, null, false, componentId, true, false, autoSubmit);
 59  0
     }
 60  
 
 61  
     /**
 62  
      * Creates a new listener binding. 
 63  
      * @param methodName
 64  
      *          The method to invoke.
 65  
      * @param formId
 66  
      *          If not null the form to submit before invoking listener
 67  
      * @param validateForm
 68  
      *          If formId is set, whether or not to validate form when submitting.
 69  
      */
 70  
     public EventBoundListener(String methodName, String formId, 
 71  
             boolean validateForm, String componentId, boolean async, boolean focus, boolean autoSubmit)
 72  0
     {
 73  0
         _methodName = methodName;
 74  0
         _formId = formId;
 75  0
         _validateForm = validateForm;
 76  0
         _componentId = componentId;
 77  0
         _async = async;
 78  0
         _focus = focus;
 79  0
         _autoSubmit = autoSubmit;
 80  0
     }
 81  
 
 82  
     /**
 83  
      * Creates a new listener binding.
 84  
      * @param methodName
 85  
      *          The method to invoke.
 86  
      * @param formId
 87  
      *          If not null the form to submit before invoking listener
 88  
      * @param validateForm
 89  
      *          If formId is set, whether or not to validate form when submitting.
 90  
      */
 91  
     public EventBoundListener(String methodName, String formId,
 92  
             boolean validateForm, String componentId, boolean async, boolean focus)
 93  
     {
 94  0
         this(methodName, formId, validateForm, componentId, async, focus, true);
 95  0
     }
 96  
     
 97  
     /**
 98  
      * @return the formId
 99  
      */
 100  
     public String getFormId()
 101  
     {
 102  0
         return _formId;
 103  
     }
 104  
 
 105  
     public void setFormId(String id)
 106  
     {
 107  0
         _formId = id;
 108  0
     }
 109  
 
 110  
     /**
 111  
      * @return the methodName
 112  
      */
 113  
     public String getMethodName()
 114  
     {
 115  0
         return _methodName;
 116  
     }
 117  
     
 118  
     /**
 119  
      * @return the componentId
 120  
      */
 121  
     public String getComponentId()
 122  
     {
 123  0
         return _componentId;
 124  
     }
 125  
 
 126  
     public void setComponentId(String id)
 127  
     {
 128  0
         _componentId = id;
 129  0
     }
 130  
 
 131  
     public void setComponentIdPath(String idPath)
 132  
     {
 133  0
         _componentIdPath = idPath;
 134  0
     }
 135  
 
 136  
     /**
 137  
      * @return the validateForm
 138  
      */
 139  
     public boolean isValidateForm()
 140  
     {
 141  0
         return _validateForm;
 142  
     }
 143  
     
 144  
     /**
 145  
      * Whether or not listener should submit form
 146  
      * asynchronously.
 147  
      * 
 148  
      * @return True if listener is asynchronous.
 149  
      */
 150  
     public boolean isAsync()
 151  
     {
 152  0
         return _async;
 153  
     }
 154  
     
 155  
     public boolean shouldFocusForm()
 156  
     {
 157  0
         return _focus;
 158  
     }
 159  
 
 160  
     public boolean isAutoSubmit()
 161  
     {
 162  0
         return _autoSubmit;
 163  
     }
 164  
 
 165  
     public String getComponentIdPath()
 166  
     {
 167  0
         return _componentIdPath;
 168  
     }
 169  
 
 170  
     public Object clone()
 171  
     throws CloneNotSupportedException
 172  
     {
 173  0
         return super.clone();
 174  
     }
 175  
 
 176  
     /**
 177  
      * {@inheritDoc}
 178  
      */
 179  
     public int hashCode()
 180  
     {
 181  0
         final int prime = 31;
 182  0
         int result = 1;
 183  0
         result = prime * result + ((_componentId == null) ? 0 : _componentId.hashCode());
 184  0
         result = prime * result + ((_methodName == null) ? 0 : _methodName.hashCode());
 185  0
         result = prime * result + ((_formId == null) ? 0 : _formId.hashCode());
 186  0
         return result;
 187  
     }
 188  
     
 189  
     /** 
 190  
      * {@inheritDoc}
 191  
      */
 192  
     public boolean equals(Object obj)
 193  
     {
 194  0
         if (this == obj) return true;
 195  0
         if (obj == null) return false;
 196  0
         if (getClass() != obj.getClass()) return false;
 197  0
         final EventBoundListener other = (EventBoundListener) obj;
 198  0
         if (_componentId == null) {
 199  0
             if (other._componentId != null) return false;
 200  0
         } else if (!_componentId.equals(other._componentId)) return false;
 201  0
         if (_methodName == null) {
 202  0
             if (other._methodName != null) return false;
 203  0
         } else if (!_methodName.equals(other._methodName)) return false;
 204  0
         return true;
 205  
     }
 206  
 }