001 // Copyright 2004, 2005 The Apache Software Foundation 002 // 003 // Licensed under the Apache License, Version 2.0 (the "License"); 004 // you may not use this file except in compliance with the License. 005 // You may obtain a copy of the License at 006 // 007 // http://www.apache.org/licenses/LICENSE-2.0 008 // 009 // Unless required by applicable law or agreed to in writing, software 010 // distributed under the License is distributed on an "AS IS" BASIS, 011 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 012 // See the License for the specific language governing permissions and 013 // limitations under the License. 014 package org.apache.tapestry.internal.event; 015 016 import org.apache.tapestry.IComponent; 017 import org.apache.tapestry.IForm; 018 import org.apache.tapestry.IRequestCycle; 019 import org.apache.tapestry.event.BrowserEvent; 020 import org.apache.tapestry.event.ResetEventListener; 021 import org.apache.tapestry.form.FormSupport; 022 import org.apache.tapestry.spec.IComponentSpecification; 023 024 import java.util.List; 025 026 027 /** 028 * Managed and handles invoking listener methods for components 029 * in response to requested event listener invocations. 030 * 031 * @author jkuhnert 032 */ 033 public interface IComponentEventInvoker extends ResetEventListener 034 { 035 /** 036 * Adds a listener mapping for events related to the specified 037 * component. 038 * 039 * @param componentId 040 * The component to map a listener with. 041 * @param listener 042 * The listener. 043 */ 044 void addEventListener(String componentId, IComponentSpecification listener); 045 046 /** 047 * Returns a list of all known listeners for the specified component. 048 * 049 * @param componentId 050 * The component id to find listeners for. 051 * @return The bound listeners, or null if none exist. 052 */ 053 List getEventListeners(String componentId); 054 055 /** 056 * Gets all bound property event listeners for the specified componentIdPath. 057 * 058 * @param componentIdPath 059 * The unique id path of the component, as returned from {@link org.apache.tapestry.IComponent#getIdPath()}. 060 * 061 * @return The aggregated array of all event properties bound to the specified component, empty if none exist. 062 */ 063 ComponentEventProperty[] getEventPropertyListeners(String componentIdPath); 064 065 /** 066 * Adds a mapping for an event listener that should be triggered when the specified 067 * form component with id of <code>formId</code> is submitted. This will later 068 * be used when the form is submitted to find event listeners bound to fire when 069 * a particular form is submitted. 070 * 071 * @param formId 072 * The form the event listener is bound to. This is the submitForm parameter 073 * of the EventListener annotation/spec driving an event occurrence to submit a particular form. It doesn't 074 * mean that the actual event target was the form . 075 * @param listener 076 * The listener that has form bound event listeners. 077 */ 078 void addFormEventListener(String formId, IComponentSpecification listener); 079 080 /** 081 * Gets a list of form bound event listeners previously bound via {@link #addFormEventListener(String, IComponentSpecification)}. 082 * 083 * @param formId 084 * The form to get mapped listeners for. 085 * @return The list of form event listeners of type {@link IComponentSpecification}, 086 * if any exist. Null if none exist. 087 */ 088 List getFormEventListeners(String formId); 089 090 /** 091 * Causes the configured listeners for the passed component to 092 * be invoked. 093 * 094 * @param component 095 * The component that recieved the invocations. 096 * @param cycle 097 * The associated request. 098 * @param event 099 * The event that started it all. 100 */ 101 void invokeListeners(IComponent component, final IRequestCycle cycle, final BrowserEvent event); 102 103 /** 104 * Causes the configured listeners for the passed {@link FormSupport}'s {@link IForm} to 105 * be invoked, if mapped to this request/event. 106 * 107 * @param formSupport 108 * The form support object being rendered. 109 * @param cycle 110 * The associated request. 111 * @param event 112 * The event that started it all. 113 */ 114 void invokeFormListeners(FormSupport formSupport, final IRequestCycle cycle, final BrowserEvent event); 115 }