Source code: com/sun/facelets/tag/jstl/core/IfHandler.java
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;
18
19 import javax.el.ELException;
20 import javax.faces.FacesException;
21 import javax.faces.component.UIComponent;
22
23 import com.sun.facelets.FaceletContext;
24 import com.sun.facelets.tag.TagAttribute;
25 import com.sun.facelets.tag.TagConfig;
26 import com.sun.facelets.tag.TagHandler;
27
28 /**
29 * @author Jacob Hookom
30 * @version $Id: IfHandler.java,v 1.4 2005/08/24 04:38:52 jhook Exp $
31 */
32 public final class IfHandler extends TagHandler {
33
34 private final TagAttribute test;
35
36 private final TagAttribute var;
37
38 /**
39 * @param config
40 */
41 public IfHandler(TagConfig config) {
42 super(config);
43 this.test = this.getRequiredAttribute("test");
44 this.var = this.getAttribute("var");
45 }
46
47 public void apply(FaceletContext ctx, UIComponent parent)
48 throws IOException, FacesException, ELException {
49 boolean b = this.test.getBoolean(ctx);
50 if (this.var != null) {
51 ctx.setAttribute(var.getValue(ctx), new Boolean(b));
52 }
53 if (b) {
54 this.nextHandler.apply(ctx, parent);
55 }
56 }
57
58 }