View Javadoc

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.view.facelets;
20  
21  import java.io.IOException;
22  import java.util.Map;
23  import java.util.Set;
24  
25  import javax.el.ELException;
26  import javax.el.ValueExpression;
27  import javax.faces.FacesException;
28  import javax.faces.component.UIComponent;
29  import javax.faces.view.facelets.Facelet;
30  import javax.faces.view.facelets.FaceletContext;
31  import javax.faces.view.facelets.FaceletException;
32  
33  /**
34   * This class is used to encapsulate the information required to resolve
35   * facelets templates.
36   * 
37   * Composite components require to "isolate" the inner template resolution.
38   * That means, when a ui:xx tag is used, do not take into account the outer
39   * templates defined.
40   * 
41   * The methods here are only used by the current implementation and the intention
42   * is not expose it as public api.
43   * 
44   * @author Leonardo Uribe (latest modification by $Author$)
45   * @version $Revision$ $Date$
46   * @since 2.0.1
47   */
48  public abstract class TemplateContext
49  {
50      /**
51       * Pop the last added pushed TemplateClient
52       * @see TemplateClient
53       */
54      public abstract TemplateManager popClient(final AbstractFaceletContext actx);
55      
56      /**
57       * Push the passed TemplateClient onto the stack for Definition Resolution
58       * @param client
59       * @see TemplateClient
60       */
61      public abstract void pushClient(final AbstractFaceletContext actx, final AbstractFacelet owner,
62                                      final TemplateClient client);
63      
64      /**
65       * Pop the last added extended TemplateClient
66       * @param actx
67       */
68      public abstract TemplateManager popExtendedClient(final AbstractFaceletContext actx);
69      
70      public abstract void extendClient(final AbstractFaceletContext actx, final AbstractFacelet owner,
71                                        final TemplateClient client);
72      
73      /**
74       * This method will walk through the TemplateClient stack to resolve and
75       * apply the definition for the passed name.
76       * If it's been resolved and applied, this method will return true.
77       * 
78       * @param parent the UIComponent to apply to
79       * @param name name or null of the definition you want to apply
80       * @return true if successfully applied, otherwise false
81       * @throws IOException
82       * @throws FaceletException
83       * @throws FacesException
84       * @throws ELException
85       */
86      public abstract boolean includeDefinition(FaceletContext ctx, Facelet owner, UIComponent parent, String name)
87              throws IOException, FaceletException, FacesException, ELException;
88      
89      public abstract TemplateManager getCompositeComponentClient();
90  
91      /**
92       * Set the composite component TemplateManager instance, used to resolve
93       * cc:insertChildred or cc:insertFacet usages for the current template
94       * context 
95       */
96      public abstract void setCompositeComponentClient(TemplateManager compositeComponentClient);
97  
98      /**
99       * Return the param value expression associated to the key passed,
100      * preserving the precedence of each template client. 
101      * 
102      * @since 2.0.8
103      * @param key
104      * @return
105      */
106     public abstract ValueExpression getParameter(String key);
107     
108     /**
109      * Associate the param to the latest template client.
110      * 
111      * @since 2.0.8
112      * @param key
113      * @return
114      */
115     public abstract void setParameter(String key, ValueExpression value);
116     
117     /**
118      * Check if no parameters are set.
119      * 
120      * @since 2.0.8
121      * @return
122      */
123     public abstract boolean isParameterEmpty();
124     
125     /**
126      * 
127      * @since 2.0.8
128      * @return
129      */
130     public abstract Map<String, ValueExpression> getParameterMap();
131 
132     /**
133      * 
134      * @since 2.0.8
135      * @return
136      */
137     public abstract boolean isAllowCacheELExpressions();
138 
139     /**
140      * 
141      * @since 2.0.8
142      * @return
143      */
144     public abstract void setAllowCacheELExpressions(boolean cacheELExpressions);
145     
146     /**
147      * 
148      * @since 2.1.12
149      * @param key
150      * @return 
151      */
152     public abstract boolean containsParameter(String key);
153     
154     /**
155      * Return a set of the parameters known associated to this template context and/or
156      * template. This logic is used to detect which EL Expressions can be cached or not.
157      * 
158      * @since 2.1.12
159      * @return 
160      */
161     public abstract Set<String> getKnownParameters();
162     
163     /**
164      * 
165      * @since 2.1.12
166      * @param key
167      * @return 
168      */
169     public abstract boolean containsKnownParameter(String key);
170     
171     /**
172      * 
173      * @since 2.1.12
174      * @return 
175      */
176     public abstract boolean isKnownParametersEmpty();
177     
178     /**
179      * 
180      * @since 2.1.12
181      * @param knownParameters 
182      */
183     public abstract void addKnownParameters(String knownParameters);
184 }