Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
SimpleAjaxShellDelegate |
|
| 1.0;1 |
1 | // Copyright 2007 The Apache Software Foundation | |
2 | // | |
3 | // Licensed under the Apache License, Version 2.0 (the "License"); | |
4 | // you may not use this file except in compliance with the License. | |
5 | // You may obtain a copy of the License at | |
6 | // | |
7 | // http://www.apache.org/licenses/LICENSE-2.0 | |
8 | // | |
9 | // 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.javascript; | |
16 | ||
17 | import org.apache.tapestry.IAsset; | |
18 | import org.apache.tapestry.IMarkupWriter; | |
19 | import org.apache.tapestry.IPage; | |
20 | import org.apache.tapestry.IRender; | |
21 | import org.apache.tapestry.IRequestCycle; | |
22 | ||
23 | /** | |
24 | * Outputs the main js packages and the tapestry js | |
25 | * that are defined by the {@link JavascriptManager} service. | |
26 | */ | |
27 | public class SimpleAjaxShellDelegate implements IRender | |
28 | { | |
29 | private JavascriptManager _javascriptManager; | |
30 | ||
31 | public SimpleAjaxShellDelegate(JavascriptManager javascriptManager) | |
32 | 0 | { |
33 | 0 | _javascriptManager = javascriptManager; |
34 | 0 | } |
35 | ||
36 | protected JavascriptManager getJavascriptManager() { | |
37 | 0 | return _javascriptManager; |
38 | } | |
39 | ||
40 | /** | |
41 | * {@inheritDoc} | |
42 | */ | |
43 | public void render(IMarkupWriter writer, IRequestCycle cycle) | |
44 | { | |
45 | 0 | IPage page = cycle.getPage(); |
46 | ||
47 | 0 | processPath(writer, cycle, _javascriptManager.getPath()); |
48 | ||
49 | 0 | _javascriptManager.renderLibraryResources(writer, cycle, page.hasFormComponents(), page.hasWidgets()); |
50 | ||
51 | 0 | processTapestryPath(writer, cycle, _javascriptManager.getTapestryPath()); |
52 | ||
53 | 0 | _javascriptManager.renderLibraryAdaptor(writer, cycle); |
54 | 0 | } |
55 | ||
56 | /** | |
57 | * Called before including any javascript. It does nothing by default, but allows | |
58 | * subclasses to change this behavior. | |
59 | * @param writer | |
60 | * @param cycle | |
61 | * @param path The base path to the javascript files. May be null. | |
62 | */ | |
63 | protected void processPath(IMarkupWriter writer, IRequestCycle cycle, IAsset path) | |
64 | { | |
65 | 0 | } |
66 | ||
67 | /** | |
68 | * Called before including tapestry's base javascript. It does nothing by default, | |
69 | * but allows subclasses to change this behavior. | |
70 | * @param writer | |
71 | * @param cycle | |
72 | * @param path The base path to the tapestry javascript file. May be null. | |
73 | */ | |
74 | protected void processTapestryPath(IMarkupWriter writer, IRequestCycle cycle, IAsset path) | |
75 | { | |
76 | 0 | } |
77 | } |