KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > sun > enterprise > tools > jsfext > layout > descriptor > LayoutIf


1 /*
2  * The contents of this file are subject to the terms
3  * of the Common Development and Distribution License
4  * (the License). You may not use this file except in
5  * compliance with the License.
6  *
7  * You can obtain a copy of the license at
8  * https://glassfish.dev.java.net/public/CDDLv1.0.html or
9  * glassfish/bootstrap/legal/CDDLv1.0.txt.
10  * See the License for the specific language governing
11  * permissions and limitations under the License.
12  *
13  * When distributing Covered Code, include this CDDL
14  * Header Notice in each file and include the License file
15  * at glassfish/bootstrap/legal/CDDLv1.0.txt.
16  * If applicable, add the following below the CDDL Header,
17  * with the fields enclosed by brackets [] replaced by
18  * you own identifying information:
19  * "Portions Copyrighted [year] [name of copyright owner]"
20  *
21  * Copyright 2006 Sun Microsystems, Inc. All rights reserved.
22  */

23 package com.sun.enterprise.tools.jsfext.layout.descriptor;
24
25 import com.sun.enterprise.tools.jsfext.el.PermissionChecker;
26
27 import javax.faces.component.UIComponent;
28 import javax.faces.context.FacesContext;
29
30
31 /**
32  * <p> This class defines a LayoutIf {@link LayoutElement}. The LayoutIf
33  * provides the functionality necessary to conditionally display a portion
34  * of the layout tree. The condition is a boolean equation and may use
35  * "$...{...}" type expressions to substitute in values.</p>
36  *
37  * @see com.sun.enterprise.tools.jsfext.el.VariableResolver
38  * @see com.sun.enterprise.tools.jsfext.el.PermissionChecker
39  *
40  * @author Ken Paulsen (ken.paulsen@sun.com)
41  */

42 public class LayoutIf extends LayoutElementBase implements LayoutElement {
43
44     /**
45      * Constructor
46      */

47     public LayoutIf(LayoutElement parent, String JavaDoc condition) {
48     super(parent, null);
49     _condition = condition;
50     }
51
52
53     /**
54      * Accessor for condition boolean equation.
55      */

56     public String JavaDoc getCondition() {
57     return _condition;
58     }
59
60
61     /**
62      * This method returns true if the condition of this LayoutIf is met,
63      * false otherwise. This provides the functionality for conditionally
64      * displaying a portion of the layout tree.
65      *
66      * @param context The FacesContext
67      * @param component The UIComponent
68      *
69      * @return true if children are to be rendered, false otherwise.
70      */

71     protected boolean encodeThis(FacesContext context, UIComponent component) {
72     PermissionChecker checker =
73         new PermissionChecker(this, component, getCondition());
74 // return checker.evaluate();
75
return checker.hasPermission();
76     }
77
78     private String JavaDoc _condition = null;
79 }
80
Popular Tags