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.context;
20
21 import java.util.Iterator;
22
23 import javax.faces.component.visit.VisitContext;
24
25
26 /**
27 * Context object which is used to track the targets of a partial
28 * page render during the Render Response phase.
29 * Clients never need to explicitly create PartialPageContext
30 * objects, but can retrieve them from a RenderingContext instance.
31 * For general access to Partial Page Rendering during all phases,
32 * see APIs on the RequestContext API.
33 * <p>
34 * During the partial rendering pass, some Renderer implementations
35 * may modify the set of partial targets that are rendered.
36 * (For example, the FormRenderer adds a partial target for its
37 * shared hidden fields.)
38 *
39 * @version $Name: $ ($Revision: adfrt/faces/adf-faces-impl/src/main/java/oracle/adfinternal/view/faces/renderkit/core/ppr/PartialPageContext.java#0 $) $Date: 10-nov-2005.19:02:58 $
40 */
41 // TODO why is this an abstract class and not an interface?
42 abstract public class PartialPageContext
43 {
44 protected PartialPageContext()
45 {
46 }
47
48 /**
49 * Tests whether the specified client id is the client id of a UIComponent that
50 * should be rendered as part of the partial rendering pass.
51 * @return <code>true</code> if a compoennt with this client id should be rendered.
52 * @see #isPossiblePartialTarget
53 */
54 abstract public boolean isPartialTarget(String clientId);
55
56 /**
57 * <p>
58 * Tests whether the specified component id is a component id of a UIComponent that
59 * might be rendered in this partial rendering pass.
60 * </p>
61 * <p>
62 * As calculating clientIds is expensive, this method allows a cheap test to reject components
63 * that shouldn't be rendered. If this method returns true, a more
64 * exact test using <code>isPartialTarget</code> with the desired clientId should be performed.
65 * </p>
66 * @return <code>true</code> if a component with this id should be rendered.
67 * @see #isPartialTarget
68 */
69 abstract public boolean isPossiblePartialTarget(String componentId);
70
71 /**
72 * Returns <code>true</code> if all of the partial targets have been rendered.
73 * @return <code>true</code> if all of the partial targets have been rendered.
74 */
75 public abstract boolean areAllTargetsProcessed();
76
77 /**
78 * Returns the set of partial targets for this rendering pass.
79 */
80 abstract public Iterator<String> getPartialTargets();
81
82 /**
83 * Tests whether the specified partial target has been rendered.
84 */
85 abstract public boolean isPartialTargetRendered(String id);
86
87 /**
88 * Adds a new partial target to render.
89 * <p>
90 * This method may be called during the partial rendering pass to
91 * add to the set of partial targets, but only if the pass has
92 * not yet been completed.
93 * @param id The id of the partial target to render
94 */
95 abstract public void addPartialTarget(String id);
96
97 /**
98 * Returns true if we are inside of a partial target.
99 */
100 abstract public boolean isInsidePartialTarget();
101
102 /**
103 * Adds a partial target that has already been rendered; this
104 * is needed if the "clientId" of a component does not match
105 * up to the top element (or elements).
106 */
107 abstract public void addRenderedPartialTarget(String id);
108
109 /**
110 * Returns the client ids of the partial targets that have been rendered so far.
111 * @return the client ids of the partial targets that have been rendered so far.
112 */
113 abstract public Iterator<String> getRenderedPartialTargets();
114
115 /**
116 * Returns the VisitContext to use when partial rendering.
117 * @return the VisitContext to use when partial rendering.
118 */
119 abstract public VisitContext getVisitContext();
120 }