Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
LegacyParamHandler |
|
| 1.0;1 |
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 | ||
20 | package org.apache.myfaces.view.facelets.tag.ui; | |
21 | ||
22 | import java.io.IOException; | |
23 | import javax.el.ELException; | |
24 | import javax.el.ValueExpression; | |
25 | import javax.faces.FacesException; | |
26 | import javax.faces.component.UIComponent; | |
27 | import javax.faces.view.facelets.FaceletContext; | |
28 | import javax.faces.view.facelets.FaceletException; | |
29 | import javax.faces.view.facelets.TagAttribute; | |
30 | import javax.faces.view.facelets.TagConfig; | |
31 | import javax.faces.view.facelets.TagHandler; | |
32 | import org.apache.myfaces.view.facelets.AbstractFaceletContext; | |
33 | ||
34 | /** | |
35 | * NOTE: This implementation is provided for compatibility reasons and | |
36 | * it is considered faulty. It is enabled using | |
37 | * org.apache.myfaces.STRICT_JSF_2_FACELETS_COMPATIBILITY web config param. | |
38 | * Don't use it if EL expression caching is enabled. | |
39 | * | |
40 | * @author Jacob Hookom | |
41 | * @version $Id: ParamHandler.java,v 1.6 2008/07/13 19:01:42 rlubke Exp $ | |
42 | */ | |
43 | //@JSFFaceletTag(name="ui:param") | |
44 | public class LegacyParamHandler extends TagHandler | |
45 | { | |
46 | ||
47 | /** | |
48 | * The name of the variable to pass to the included Facelet. | |
49 | */ | |
50 | //@JSFFaceletAttribute( | |
51 | // className="javax.el.ValueExpression", | |
52 | // deferredValueType="java.lang.String", | |
53 | // required=true) | |
54 | private final TagAttribute name; | |
55 | ||
56 | /** | |
57 | * The literal or EL expression value to assign to the named variable. | |
58 | */ | |
59 | //@JSFFaceletAttribute( | |
60 | // className="javax.el.ValueExpression", | |
61 | // deferredValueType="java.lang.String", | |
62 | // required=true) | |
63 | private final TagAttribute value; | |
64 | ||
65 | /** | |
66 | * @param config | |
67 | */ | |
68 | public LegacyParamHandler(TagConfig config) | |
69 | { | |
70 | 0 | super(config); |
71 | 0 | this.name = this.getRequiredAttribute("name"); |
72 | 0 | this.value = this.getRequiredAttribute("value"); |
73 | 0 | } |
74 | ||
75 | /* | |
76 | * (non-Javadoc) | |
77 | * | |
78 | * @see javax.faces.view.facelets.FaceletHandler#apply(javax.faces.view.facelets.FaceletContext, | |
79 | * javax.faces.component.UIComponent) | |
80 | */ | |
81 | public void apply(FaceletContext ctx, UIComponent parent) throws IOException, FacesException, FaceletException, | |
82 | ELException | |
83 | { | |
84 | 0 | String nameStr = getName(ctx); |
85 | 0 | ValueExpression valueVE = getValue(ctx); |
86 | //ctx.getVariableMapper().setVariable(nameStr, valueVE); | |
87 | 0 | apply(ctx, parent, nameStr, valueVE); |
88 | 0 | } |
89 | ||
90 | public void apply(FaceletContext ctx, UIComponent parent, String nameStr, ValueExpression valueVE) | |
91 | throws IOException, FacesException, FaceletException, ELException | |
92 | { | |
93 | 0 | ctx.getVariableMapper().setVariable(nameStr, valueVE); |
94 | 0 | AbstractFaceletContext actx = ((AbstractFaceletContext) ctx); |
95 | 0 | actx.getTemplateContext().setAllowCacheELExpressions(false); |
96 | 0 | } |
97 | ||
98 | public String getName(FaceletContext ctx) | |
99 | { | |
100 | 0 | return this.name.getValue(ctx); |
101 | } | |
102 | ||
103 | public ValueExpression getValue(FaceletContext ctx) | |
104 | { | |
105 | 0 | return this.value.getValueExpression(ctx, Object.class); |
106 | } | |
107 | } |