KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > facelets > tag > ui > IncludeHandler


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.ui;
16
17 import java.io.IOException JavaDoc;
18
19 import javax.el.ELException;
20 import javax.el.VariableMapper;
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.el.VariableMapperWrapper;
27 import com.sun.facelets.tag.TagAttribute;
28 import com.sun.facelets.tag.TagConfig;
29 import com.sun.facelets.tag.TagHandler;
30
31 /**
32  * @author Jacob Hookom
33  * @version $Id: IncludeHandler.java,v 1.3 2005/08/24 04:38:55 jhook Exp $
34  */

35 public final class IncludeHandler extends TagHandler {
36
37     private final TagAttribute src;
38
39     /**
40      * @param config
41      */

42     public IncludeHandler(TagConfig config) {
43         super(config);
44         this.src = this.getRequiredAttribute("src");
45     }
46
47     /*
48      * (non-Javadoc)
49      *
50      * @see com.sun.facelets.FaceletHandler#apply(com.sun.facelets.FaceletContext,
51      * javax.faces.component.UIComponent)
52      */

53     public void apply(FaceletContext ctx, UIComponent parent)
54             throws IOException JavaDoc, FacesException, FaceletException, ELException {
55         String JavaDoc path = this.src.getValue(ctx);
56         VariableMapper orig = ctx.getVariableMapper();
57         ctx.setVariableMapper(new VariableMapperWrapper(orig));
58         try {
59             this.nextHandler.apply(ctx, null);
60             ctx.includeFacelet(parent, path);
61         } finally {
62             ctx.setVariableMapper(orig);
63         }
64     }
65 }
66
Popular Tags