001    /*
002     * Licensed under the Apache License, Version 2.0 (the "License");
003     * you may not use this file except in compliance with the License.
004     * You may obtain a copy of the License at
005     *
006     * http://www.apache.org/licenses/LICENSE-2.0
007     *
008     * Unless required by applicable law or agreed to in writing, software
009     * distributed under the License is distributed on an "AS IS" BASIS,
010     * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
011     * See the License for the specific language governing permissions and
012     * limitations under the License.
013     * 
014     * See the NOTICE file distributed with this work for additional
015     * information regarding copyright ownership.
016     */
017    
018    package com.osbcp.apbs.events;
019    
020    import java.io.Serializable;
021    import java.util.HashMap;
022    import java.util.Map;
023    
024    import com.osbcp.jjsw.JavaScript;
025    
026    /**
027     * An ajax post back event
028     * 
029     * @author <a href="mailto:christoffer@christoffer.me">Christoffer Pettersson</a>
030     */
031    
032    public abstract class AjaxPostBackEvent {
033    
034            private Map<Serializable, Object> metaData = new HashMap<Serializable, Object>();
035    
036            /**
037             * Returns a JavaScript response that should be performed by the browser.
038             * 
039             * @return A JavaScript response that should be performed by the browser.
040             */
041    
042            public abstract JavaScript getJavaScriptResponse();
043    
044            /**
045             * Returns a map of meta data included in the event, defined in the AjaxPostBackServlet.
046             * 
047             * @param key A unique key in the map.
048             * @return The meta data object associated with the key.
049             */
050    
051            public Object getMetaData(final Serializable key) {
052                    return metaData.get(key);
053            }
054    
055            /**
056             * Sets a specific meta data object associated with a unique key.
057             * 
058             * @param metaData The meta data object.
059             */
060    
061            public void setMetaData(final Map<Serializable, Object> metaData) {
062                    this.metaData = metaData;
063            }
064    
065    }