01: // Copyright 2006, 2007 The Apache Software Foundation
02: //
03: // Licensed under the Apache License, Version 2.0 (the "License");
04: // you may not use this file except in compliance with the License.
05: // You may obtain a copy of the License at
06: //
07: // http://www.apache.org/licenses/LICENSE-2.0
08: //
09: // 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:
15: package org.apache.tapestry;
16:
17: import org.apache.tapestry.ioc.internal.util.IdAllocator;
18:
19: /**
20: * Provides support to all components that render. This is primarily about generating unique
21: * client-side ids (very important for JavaScript generation) as well as accumulating JavaScript to
22: * be sent to the client.
23: */
24: public interface PageRenderSupport {
25: /**
26: * Allocates a unique id based on the component's id. In some cases, the return value will not
27: * precisely match the input value (an underscore and a unique index value may be appended).
28: *
29: * @param id
30: * the component id from which a unique id will be generated
31: * @return a unqiue id for this rendering of the page
32: * @see IdAllocator
33: */
34: String allocateClientId(String id);
35:
36: /**
37: * Adds one or more new script assets to the page. Assets are added uniquely, and appear as
38: * <script> elements just inside the <body> element of the rendered page. Duplicate
39: * requests to add the same script are quietly ignored.
40: *
41: * @param scriptAssets
42: * asset to the script to add
43: */
44: void addScriptLink(Asset... scriptAssets);
45:
46: /**
47: * Used to add scripts that are stored on the classpath. Each element has symbol expanded, then
48: * is converted to an asset and added as a script link.
49: *
50: * @param classpaths
51: * array of paths. Symbols in the paths are expanded, then the paths are each
52: * converted into an asset.
53: */
54: void addClasspathScriptLink(String... classpaths);
55:
56: /**
57: * Adds a script statement to the page's script block (which appears at the end of the page,
58: * just before the </body> tag).
59: *
60: * @param format
61: * base string format, to be passed through String.format
62: * @param arguments
63: * additional arguments formatted to form the final script
64: */
65: void addScript(String format, Object... arguments);
66: }
|