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 015package org.apache.tapestry.contrib.ajax; 016 017import java.util.HashMap; 018import java.util.Map; 019 020import org.apache.tapestry.BaseComponent; 021import org.apache.tapestry.IActionListener; 022import org.apache.tapestry.IRequestCycle; 023import org.apache.tapestry.Tapestry; 024import org.apache.tapestry.engine.IEngineService; 025import org.apache.tapestry.engine.ILink; 026 027/** 028 * @author mindbridge 029 * @author Paul Green 030 * @since 4.0 031 */ 032public abstract class XTile extends BaseComponent implements IXTile 033{ 034 public abstract IActionListener getListener(); 035 036 public abstract String getSendName(); 037 038 public abstract String getReceiveName(); 039 040 public abstract String getErrorName(); 041 042 public abstract boolean getDisableCaching(); 043 044 // Injected 045 046 public abstract IEngineService getService(); 047 048 public void trigger(IRequestCycle cycle) 049 { 050 IActionListener listener = getListener(); 051 052 if (listener == null) 053 throw Tapestry.createRequiredParameterException(this, "listener"); 054 055 listener.actionTriggered(this, cycle); 056 } 057 058 public Map getScriptSymbols() 059 { 060 ILink link = getService().getLink(false, this); 061 062 Map result = new HashMap(); 063 064 result.put("sendFunctionName", getSendName()); 065 result.put("receiveFunctionName", getReceiveName()); 066 result.put("errorFunctionName", getErrorName()); 067 result.put("disableCaching", getDisableCaching() ? "true" : null); 068 result.put("url", link.getURL()); 069 070 return result; 071 } 072 073}