1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.trinidad.render;
20
21 import java.io.IOException;
22 import javax.faces.context.FacesContext;
23
24 /**
25 * <p>
26 * Service implemented by RenderKits that provide further
27 * support for per-page rendering actions, like including
28 * scripts global to a page or short-circuiting rendering
29 * altogether. Developers should always retrieve
30 * an instance using {@link org.apache.myfaces.trinidad.util.Service#getService},
31 * passing in the current RenderKit, or with
32 * {@link org.apache.myfaces.trinidad.util.Service#getRenderKitService},
33 * </p>
34 * <p><b>Example:</b> The following code will add a script
35 * to be rendered during the following request:
36 * <pre>
37 * ExtendedRenderKitService service =
38 * Service.getRenderKitService(facesContext, ExtendedRenderKitService.class);
39 * service.addScript(facesContext, "alert('foo');");
40 * </pre>
41 * </p>
42 */
43 public interface ExtendedRenderKitService
44 {
45 /**
46 * Adds a script for execution during rendering.
47 */
48 public void addScript(FacesContext context, String script);
49
50 /**
51 * Output any needed scripts required by the RenderKit
52 * for this page.
53 */
54 public void encodeScripts(
55 FacesContext context) throws IOException;
56
57 /**
58 * Called to short-circuit rendering the view.
59 * A ViewHandler should call this method before
60 * rendering the view (for example, before forwarding to a JSP),
61 * and if it returns true, do nothing further.
62 */
63 public boolean shortCircuitRenderView(
64 FacesContext context) throws IOException;
65
66 public boolean isStateless(
67 FacesContext context);
68
69 /**
70 * Called when the encoding of a page begins.
71 */
72 public void encodeBegin(FacesContext context) throws IOException;
73
74 /**
75 * Called when the encoding of a page ends, if there were no exceptions.
76 */
77 public void encodeEnd(FacesContext context) throws IOException;
78
79 /**
80 * Called when the encoding of a page completes, whether or not there
81 * were exceptions.
82 */
83 public void encodeFinally(FacesContext context);
84 }