KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > facelets > tag > jstl > core > SetHandler


1 /**
2  * Licensed under the Common Development and Distribution License,
3  * you may not use this file except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://www.sun.com/cddl/
7  *
8  * Unless required by applicable law or agreed to in writing, software
9  * distributed under the License is distributed on an "AS IS" BASIS,
10  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11  * implied. See the License for the specific language governing
12  * permissions and limitations under the License.
13  */

14
15 package com.sun.facelets.tag.jstl.core;
16
17 import java.io.IOException JavaDoc;
18
19 import javax.el.ELException;
20 import javax.el.ValueExpression;
21 import javax.faces.FacesException;
22 import javax.faces.component.UIComponent;
23
24 import com.sun.facelets.FaceletContext;
25 import com.sun.facelets.FaceletException;
26 import com.sun.facelets.tag.TagAttribute;
27 import com.sun.facelets.tag.TagConfig;
28 import com.sun.facelets.tag.TagHandler;
29
30 /**
31  * Simplified implementation of c:set
32  *
33  * @author Jacob Hookom
34  * @version $Id: SetHandler.java,v 1.1 2006/01/07 15:32:07 jhook Exp $
35  */

36 public class SetHandler extends TagHandler {
37
38     private final TagAttribute var;
39     
40     private final TagAttribute value;
41     
42     public SetHandler(TagConfig config) {
43         super(config);
44         this.value = this.getRequiredAttribute("value");
45         this.var = this.getRequiredAttribute("var");
46     }
47
48     public void apply(FaceletContext ctx, UIComponent parent)
49             throws IOException JavaDoc, FacesException, FaceletException, ELException {
50         String JavaDoc varStr = this.var.getValue(ctx);
51         ValueExpression veObj = this.value.getValueExpression(ctx, Object JavaDoc.class);
52         ctx.getVariableMapper().setVariable(varStr, veObj);
53     }
54 }
55
Popular Tags