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; 016 017import org.apache.hivemind.Resource; 018 019/** 020 * Defines methods needed by a {@link org.apache.tapestry.IScript}to execute. 021 * 022 * @author Howard Lewis Ship 023 * @since 3.0 024 * @see org.apache.tapestry.html.Body 025 */ 026 027public interface IScriptProcessor 028{ 029 /** 030 * Adds scripting code to the main body. During the render, multiple scripts may render multiple 031 * bodies; all are concatinated together to form a single block. The 032 * {@link org.apache.tapestry.html.Body} component will write the body script contents 033 * just inside the <code><body></code> tag. 034 */ 035 036 public void addBodyScript(String script); 037 038 /** 039 * Adds initialization script. Initialization script is executed once, when the containing page 040 * loads. Initialization script content is written only after all HTML content that could be 041 * referenced from the script (in effect, just before the <code></body> tag). 042 */ 043 public void addInitializationScript(String script); 044 045 /** 046 * Adds an external script. The processor is expected to ensure that external scripts are only 047 * loaded a single time per page. 048 */ 049 050 public void addExternalScript(Resource resource); 051 052 /** 053 * Ensures that the given string is unique. The string is either returned unchanged, or a suffix 054 * is appended to ensure uniqueness. 055 */ 056 057 public String getUniqueString(String baseValue); 058}